streams
Creates, updates, deletes, gets or lists a streams resource.
Overview
| Name | streams |
| Type | Resource |
| Id | snowflake.tables.streams |
Fields
The following fields are returned by SELECT queries:
- get
- list
successful
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | Database in which the stream is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | Schema in which the stream is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
table_name | string | Table name whose changes are tracked by the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
comment | string | user comment associated to an object in the dictionary |
created_on | string (date-time) | Date and time when the stream was created. |
invalid_reason | string | Reason why the stream cannot be queried successfully. This column supports future functionality. Currently, the only value returned is N/A. |
mode | string | Mode of the stream. Possible values include: APPEND_ONLY, INSERT_ONLY. For streams on tables, the column displays DEFAULT. |
owner | string | Role that owns the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
stale | boolean | Specifies whether the stream is stale or not |
stale_after | string (date-time) | Timestamp when the stream became stale or may become stale if not consumed. |
stream_source | object | Source for the stream |
type | string | Type of the stream; currently DELTA only. |
A Snowflake stream
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | Database in which the stream is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | Schema in which the stream is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
table_name | string | Table name whose changes are tracked by the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
comment | string | user comment associated to an object in the dictionary |
created_on | string (date-time) | Date and time when the stream was created. |
invalid_reason | string | Reason why the stream cannot be queried successfully. This column supports future functionality. Currently, the only value returned is N/A. |
mode | string | Mode of the stream. Possible values include: APPEND_ONLY, INSERT_ONLY. For streams on tables, the column displays DEFAULT. |
owner | string | Role that owns the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the stream (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
stale | boolean | Specifies whether the stream is stale or not |
stale_after | string (date-time) | Timestamp when the stream became stale or may become stale if not consumed. |
stream_source | object | Source for the stream |
type | string | Type of the stream; currently DELTA only. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | database_name, schema_name, name, endpoint | Fetch a stream | |
list | select | database_name, schema_name, endpoint | like, startsWith, showLimit, fromName | List streams |
create | insert | database_name, schema_name, endpoint, name, stream_source | createMode, copyGrants | Create a stream |
delete | delete | database_name, schema_name, name, endpoint | ifExists | Delete a stream |
clone | exec | database_name, schema_name, name, targetDatabase, targetSchema, endpoint, name | createMode, copyGrants | Clone a stream |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
database_name | string | Identifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
endpoint | string | Organization and account identifier (orgname-accountname) (default: orgname-accountname) |
name | string | Identifier (i.e. name) for the resource. |
schema_name | string | Identifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
targetDatabase | string | Database of the target resource. Defaults to the source's database |
targetSchema | string | Schema of the target resource. Defaults to the source's schema |
copyGrants | boolean | Parameter to enable copy grants when creating the object. |
createMode | string | 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. |
fromName | string | 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. |
ifExists | boolean | 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. |
like | string | Parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
showLimit | integer | Parameter to limit the maximum number of rows returned by a command. |
startsWith | string | 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. |
SELECT examples
- get
- list
Fetch a stream
SELECT
name,
database_name,
schema_name,
table_name,
comment,
created_on,
invalid_reason,
mode,
owner,
owner_role_type,
stale,
stale_after,
stream_source,
type
FROM snowflake.tables.streams
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;
List streams
SELECT
name,
database_name,
schema_name,
table_name,
comment,
created_on,
invalid_reason,
mode,
owner,
owner_role_type,
stale,
stale_after,
stream_source,
type
FROM snowflake.tables.streams
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND "like" = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}'
;
INSERT examples
- create
- Manifest
Create a stream
INSERT INTO snowflake.tables.streams (
name,
stream_source,
comment,
database_name,
schema_name,
endpoint,
createMode,
copyGrants
)
SELECT
'{{ name }}' /* required */,
'{{ stream_source }}' /* required */,
'{{ comment }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}',
'{{ copyGrants }}'
RETURNING
status
;
# Description fields are for documentation purposes
- name: streams
props:
- name: database_name
value: "{{ database_name }}"
description: Required parameter for the streams resource.
- name: schema_name
value: "{{ schema_name }}"
description: Required parameter for the streams resource.
- name: endpoint
value: "{{ endpoint }}"
description: Required parameter for the streams resource.
- name: name
value: "{{ name }}"
description: |
Name of the stream
- name: stream_source
description: |
Source for the stream
value:
src_type: "{{ src_type }}"
name: "{{ name }}"
database_name: "{{ database_name }}"
schema_name: "{{ schema_name }}"
- name: comment
value: "{{ comment }}"
description: |
user comment associated to an object in the dictionary
- name: createMode
value: "{{ createMode }}"
description: 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.
description: 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.
- name: copyGrants
value: {{ copyGrants }}
description: Parameter to enable copy grants when creating the object.
description: Parameter to enable copy grants when creating the object.
DELETE examples
- delete
Delete a stream
DELETE FROM snowflake.tables.streams
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
;
Lifecycle Methods
- clone
Clone a stream
EXEC snowflake.tables.streams.clone
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@targetDatabase='{{ targetDatabase }}' --required,
@targetSchema='{{ targetSchema }}' --required,
@endpoint='{{ endpoint }}' --required,
@createMode='{{ createMode }}',
@copyGrants={{ copyGrants }}
@@json=
'{
"name": "{{ name }}",
"comment": "{{ comment }}"
}'
;