Provider.create_streams()#

relationalai
#Provider.create_streams(sources: list[str], model:str, force:bool=False) -> None

Creates data streams from one or more Snowflake tables or views to a RelationalAI (RAI) model. At least one engine with a READY state must be available to create a data stream. You must have SELECT privileges and change tracking must be enabled on the source object. See Supported Column Types for a list of column types supported in a data stream’s source table or view. Requires the cdc_admin application role.

Stream data from Snowflake tables into a model and block until the streams are ready. Requires the Snowflake user set in your configuration to have the cdc_admin application role.

Parameters#

NameTypeDescription
sourceslist[str]List of Snowflake tables to stream data from. Table names must be fully qualified with the Snowflake database and schema names, e.g. "<db_name>.<schema_name>.<table_name>".
modelstrName of the model to stream data into.
forceboolWhether to force the recreation of streams if they already exist. (Default: False)

Returns#

None

Example#

Use .create_streams() to stream data from Snowflake tables into a model:

#import relationalai as rai

# Create a model.
model = rai.model("MyModel")

# Stream data from Snowflake tables into the model.
app = rai.Provider()
app.create_streams(
    model=model.name,
    sources=[
        "my_db.my_schema.my_table1",
        "my_db.my_schema.my_table2",
    ]
)

# After streams are created, you can use them as sources for types.
Type1 = model.Type("Type1", source="my_db.my_schema.my_table1")
Type2 = model.Type("Type2", source="my_db.my_schema.my_table2")

See Data Management for more information on managing data streams.

See Also#