CREATE EXTERNAL TABLE … ENGINE = DATASTREAM¶
Create a MatrixOne external table that reads rows from a remote DataStream (jstfu) server via the
ENGINE = DATASTREAMclause. The table is read-only, requiresserver,port, andtableoptions, and supports optionalrecheckandapikeyoptions.
Description¶
CREATE EXTERNAL TABLE ... ENGINE = DATASTREAM maps a MatrixOne external table to a data source served by a remote DataStream (jstfu) server. MatrixOne streams rows from the server on demand when the table is queried. The table is read-only: SELECT is supported, and writes (INSERT, UPDATE, and DELETE) are rejected.
The statement must provide the server, port, and table options. The optional recheck option controls whether predicates pushed down to the server are re-applied locally, and the optional apikey option presents a shared secret to the server.
Syntax¶
CREATE EXTERNAL TABLE [IF NOT EXISTS] [db.]table_name (
column1 type1,
column2 type2,
...
) ENGINE = DATASTREAM [WITH ("option" = 'value' [, "option" = 'value'] ...)];
Arguments¶
Option |
Required |
Description |
|---|---|---|
|
Yes |
Hostname or IP address of the DataStream server. |
|
Yes |
Port number of the DataStream server. Must be a valid port number; a non-numeric value is rejected. |
|
Yes |
Name of the data source to read on the server. |
|
No |
Whether MatrixOne re-applies pushed-down predicates locally. |
|
No |
Optional shared secret presented to the server. A value of the form |
Usage Notes¶
Read-only: external tables backed by DataStream reject
INSERT,UPDATE, andDELETEwithcannot insert/update/delete from external table.Option validation: options are validated when the table is created. Duplicate, unknown, or invalid options are rejected with an
invalid inputerror.Secret redaction:
SHOW CREATE TABLEround-trips the DDL but never displays theapikeyvalue.Filter recheck: a non-pushable predicate always stays local, so it is still applied even when
recheckis set tofalse.
Examples¶
The following example creates two DataStream external tables, inspects their DDL with SHOW CREATE TABLE, and demonstrates a validation error for a missing required option:
DROP DATABASE IF EXISTS datastream_doc_demo;
CREATE DATABASE datastream_doc_demo;
USE datastream_doc_demo;
CREATE EXTERNAL TABLE ext_file (
col1 INT,
col2 DATETIME,
col3 VARCHAR(50),
col4 TEXT
) ENGINE = DATASTREAM WITH ('server' = '127.0.0.1', 'port' = '4444', 'table' = 'file_numbers');
SHOW CREATE TABLE ext_file;
CREATE EXTERNAL TABLE ext_keyed (
col1 INT,
col2 DATETIME,
col3 VARCHAR(50),
col4 TEXT
) ENGINE = DATASTREAM WITH ('server' = '127.0.0.1', 'port' = '4444', 'table' = 'jdbc_numbers', 'recheck' = 'false', 'apikey' = 'top-secret');
SHOW CREATE TABLE ext_keyed;
-- Expected-Success: false
CREATE EXTERNAL TABLE ds_missing_port (a INT) ENGINE = DATASTREAM WITH ('server' = '127.0.0.1');
DROP DATABASE datastream_doc_demo;