create_data_stream()#
#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#
Name | Type | Description |
---|---|---|
source_table_reference | OBJECT_REFERENCE | A reference to the source table or view in Snowflake. |
stream_name | STRING | The 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'
);
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.