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 ParamsOptional ParamsDescription
fetch_streamSELECTdatabase_name, name, schema_name, endpoint-Fetch a stream
list_streamsSELECTdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromNameList streams
create_streamINSERTdatabase_name, schema_name, data__name, data__stream_source, endpointcreateMode, copyGrantsCreate a stream
delete_streamDELETEdatabase_name, name, schema_name, endpointifExistsDelete a stream
clone_streamEXECdatabase_name, name, schema_name, targetDatabase, targetSchema, data__name, endpointcreateMode, copyGrantsClone a stream

Optional Parameter Details
NameDescriptionTypeDefault
copyGrantsQuery parameter to enable copy grants when creating the object.booleanfalse
createModeQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.stringerrorIfExists
fromNameQuery parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.string-
ifExistsQuery parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.booleanfalse
likeQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.string-
showLimitQuery parameter to limit the maximum number of rows returned by a command.integer-
startsWithQuery parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.string-

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 }}';