YMatrix
Quick Start
Simulate Time Series Scenarios
Standard Cluster Deployment
Data Modeling
Connecting to The database
Data Writing
Data Migration
Data Query
Scene Application Examples
Federal Query
Maintenance and Monitoring
Global Maintenance
Partition Maintenance
Backup and Restore
Cluster Expansion
Monitoring
Performance Tuning
Troubleshooting
Reference Guide
Tool Guide
Data Type
Storage Engine
Execution Engine
Stream Processing
DR (Disaster Recovery)
Configuration Parameters
Index
Extension
SQL Reference
FAQ
Define a stream.
CREATE STREAM [IF NOT EXISTS] stream_name [ (column_name [, ...] ) ]
AS(
SELECT [ { * | expression [ [ AS ] output_name ] } [, ...] ]
FROM STREAMING { ALL | INSERT |UPDATE | DELETE } table_name
[ WHERE condition ]
[ join_type ]
[ GROUP BY grouping_element [, ...] ]
[ WITH [ NO ] DATA ]
)
[ USING MARS3 ]
[ WITH ( storage_parameter [= value] [, ... ] ) ]
[ DISTRIBUTED BY ( [column_name [, ...] ] ) ]
CREATE STREAM declares the definition of a stream and defines internal management functions within the database.
stream_name [ (column_name [, ...] ) ]
stream_name
: flow table. If as the end of the stream, the calculation result of the stream is stored. (column_name [, ...] )
: Field map, can be omitted. When omitting, the field information listed in the SELECT section of the AS statement block is used by default.AS
SELECT [ { * | expression [ [ AS ] output_name ] } [, ...] ]
FROM STREAMING { ALL | INSERT |UPDATE | DELETE } table_name
FROM STREAMING
declares that data is incrementally subscribed from the source table in a stream, and a set of processes will be started inside the corresponding database to monitor the data changes on the table.ALL | INSERT |UPDATE | DELETE
Select the subscription method of the stream from the source table, that is, to monitor a certain type of data change in the source table. ALL
is used to monitor the insertion, update and delete changes of source table data; INSERT
is used to monitor the insertion changes of source table; UPDATE
is used to monitor the update operation of source table; DELETE
is used to monitor the delete operation of source table.table_name
source table (upstream table) of the stream.join_type
[ INNER ] JOIN
operations are supported, LEFT [OUTER] JOIN
, RIGHT [OUTER] JOIN
, etc. [OUTER] JOIN
operations will be updated in subsequent versions.WITH [NO] DATA
USING MARS3
WITH ( storage_parameter [= value] [, ... ] )
DISTRIBUTED BY ( [column_name [, ...] ] )
Create a basic stream.
CREATE STREAM s1(id, c1, ts, arrive_s1)
AS (
SELECT *, clock_timestamp()
FROM STREAMING t1
WITH NO DATA
)
DISTRIBUTED BY (id);
Create a stream that uses the MARS3 engine and specifies data compression types and levels.
CREATE STREAM s4(id, c1, ts, arrive_s4)
AS (
SELECT *, clock_timestamp()
FROM STREAMING t4
WITH NO DATA
)
USING mars3
WITH (compresstype='zstd', compresslevel=1)
DISTRIBUTED BY (id, arrive_s4);
For more information, please refer to Flow calculation function example