create_data_stream()#

relationalai.<rai_schema>
#create_data_stream(<source_table_reference>, <stream_name>)

Creates a new Change Data Capture (CDC) stream within a specified RelationalAI (RAI) schema. This stream captures changes from a specified Snowflake table or view and ingests the data into the RAI schema. Requires the cdc_admin or <rai_schema>_cdc application role.

Parameters#

NameTypeDescription
source_table_referenceOBJECT_REFERENCEA reference to the source table or view in Snowflake.
stream_nameSTRINGThe name of the stream to create. Must be unique within the schema.

Example#

Use create_data_stream() to create a new CDC data stream within a RAI schema. Ensure change tracking is enabled on the source table or view and that you have SELECT privileges. Before calling create_data_stream(), create a reference to the source table or view using object_reference().

For example, to create a new stream named my_stream for a table my_table in the schema my_db.my_schema:

#CALL relationalai.my_schema.create_data_stream(
    relationalai.api.object_reference('TABLE', 'my_db.my_schema.my_table'),
    'my_stream'
);
IMPORTANT

You may create references for up to 100 tables and 100 views in a single RAI schema, for a total of 200 source objects per schema. Each source object may have multiple streams associated with it.

See Also#