Skip to main content

streams

Creates, updates, deletes, gets or lists a streams resource.

Overview

Namestreams
TypeResource
Idsnowflake.streams.streams

Fields

NameDatatypeDescription
namestringName of the stream
commentstringuser comment associated to an object in the dictionary
created_onstringDate and time when the stream was created.
database_namestringDatabase in which the stream is stored
invalid_reasonstringReason why the stream cannot be queried successfully. This column supports future functionality. Currently, the only value returned is N/A.
modestringMode of the stream. Possible values include: APPEND_ONLY, INSERT_ONLY. For streams on tables, the column displays DEFAULT.
ownerstringRole that owns the stream
owner_role_typestringThe type of role that owns the stream
schema_namestringSchema in which the stream is stored
stalebooleanSpecifies whether the stream is stale or not
stale_afterstringTimestamp when the stream became stale or may become stale if not consumed.
stream_sourceobject
table_namestringTable name whose changes are tracked by the stream
typestringType of the stream; currently DELTA only.

Methods

NameAccessible byRequired ParamsDescription
fetch_streamSELECTdatabase_name, name, schema_name, endpointFetch a stream
list_streamsSELECTdatabase_name, schema_name, endpointList streams
create_streamINSERTdatabase_name, schema_name, data__name, data__stream_source, endpointCreate a stream
delete_streamDELETEdatabase_name, name, schema_name, endpointDelete a stream
clone_streamEXECdatabase_name, name, schema_name, targetDatabase, targetSchema, data__name, endpointClone a stream

SELECT examples

List streams

SELECT
name,
comment,
created_on,
database_name,
invalid_reason,
mode,
owner,
owner_role_type,
schema_name,
stale,
stale_after,
stream_source,
table_name,
type
FROM snowflake.streams.streams
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';

INSERT example

Use the following StackQL query and manifest file to create a new streams resource.

/*+ create */
INSERT INTO snowflake.streams.streams (
data__name,
data__stream_source,
data__comment,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ stream_source }}',
'{{ comment }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;

DELETE example

Deletes the specified streams resource.

/*+ delete */
DELETE FROM snowflake.streams.streams
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';