Skip to main content

dynamic_tables

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

Overview

Namedynamic_tables
TypeResource
Idsnowflake.tables.dynamic_tables

Fields

The following fields are returned by SELECT queries:

successful

NameDatatypeDescription
namestringSpecifies the name for the dynamic table, must be unique for the schema in which the dynamic table is created
database_namestringDatabase in which the dynamic table is stored
schema_namestringSchema in which the dynamic table is stored
automatic_clusteringbooleanIf Automatic Clustering is enabled for your account, specifies whether it is explicitly enabled or disabled for the dynamic table.
budgetstringName of the budget if the object is monitored by a budget
bytesinteger (int64)Number of bytes that will be scanned if the entire table is scanned in a query. Note that this number may be different than the number of actual physical bytes stored on-disk for the table
cluster_byarraySpecifies one or more columns or column expressions in the dynamic table as the clustering key
columnsarray
commentstringSpecifies a comment for the dynamic table.
created_onstring (date-time)Date and time when the dynamic table was created.
data_retention_time_in_daysintegerSpecifies the retention period for the dynamic table so that Time Travel actions (SELECT, CLONE) can be performed on historical data in the dynamic table
initializestringSpecifies the behavior of the initial refresh of the dynamic table (ON_CREATE, ON_SCHEDULE)
kindstringSpecifies the dynamic table type, permanent (default) or transient. (PERMANENT, TRANSIENT) (default: PERMANENT)
max_data_extension_time_in_daysintegerSpecifies the retention period for the dynamic table so that Time Travel actions (SELECT, CLONE) can be performed on historical data in the dynamic table
ownerstringRole that owns the table
owner_role_typestringThe type of role that owns the object.
querystringSpecifies the query whose results the dynamic table should contain (example: SELECT * FROM foo)
refresh_modestringSpecifies the refresh type for the dynamic table (AUTO, FULL, INCREMENTAL)
rowsinteger (int64)Number of rows in the dynamic table.
scheduling_statestringScheduling state (RUNNING or SUSPENDED) (RUNNING, SUSPENDED)
target_lagobjectSpecifies the schedule for periodically refreshing the dynamic table.
warehousestringSpecifies the name of the warehouse that provides the compute resources for refreshing the dynamic table (example: test_wh)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdatabase_name, schema_name, name, endpointFetch a Dynamic Table.
listselectdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromName, deepLists the dynamic tables under the database and schema.
createinsertdatabase_name, schema_name, endpoint, name, target_lag, warehouse, querycreateModeCreate a dynamic table, with standard create modifiers as query parameters. See the Dynamic Table component definition for what is required to be provided in the request body.
deletedeletedatabase_name, schema_name, name, endpointifExistsDelete a dynamic table with the given name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful.
cloneexecdatabase_name, schema_name, name, endpoint, namecreateMode, copyGrants, targetDatabase, targetSchemaCreate a new dynamic table by cloning from the specified resource
undropexecdatabase_name, schema_name, name, endpointUndrop specified dynamic table
suspendexecdatabase_name, schema_name, name, endpointifExistsSuspend refreshes on the dynamic table
resumeexecdatabase_name, schema_name, name, endpointifExistsResume refreshes on the dynamic table
refreshexecdatabase_name, schema_name, name, endpointifExistsSpecifies that the dynamic table should be manually refreshed
suspend_reclusterexecdatabase_name, schema_name, name, endpointifExistsSuspend recluster of a dynamic table
resume_reclusterexecdatabase_name, schema_name, name, endpointifExistsResume recluster of a dynamic table
swap_withexecdatabase_name, schema_name, name, targetName, endpointifExists, targetDatabase, targetSchemaSwap with another dynamic table

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.

NameDatatypeDescription
database_namestringIdentifier (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.
endpointstringOrganization and account identifier (orgname-accountname) (default: orgname-accountname)
namestringIdentifier (i.e. name) for the resource.
schema_namestringIdentifier (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.
targetNamestringThe name of the target dynamic table to be swapped with.
copyGrantsbooleanParameter to enable copy grants when creating the object.
createModestringParameter 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.
deepbooleanOptionally includes dependency information of the dynamic table.
fromNamestringParameter 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.
ifExistsbooleanParameter 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.
likestringParameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerParameter to limit the maximum number of rows returned by a command.
startsWithstringParameter 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.
targetDatabasestringDatabase of the target dynamic table. Defaults to the source table's database.
targetSchemastringSchema of the target dynamic table. Defaults to the source table's schema.

SELECT examples

Fetch a Dynamic Table.

SELECT
name,
database_name,
schema_name,
automatic_clustering,
budget,
bytes,
cluster_by,
columns,
comment,
created_on,
data_retention_time_in_days,
initialize,
kind,
max_data_extension_time_in_days,
owner,
owner_role_type,
query,
refresh_mode,
rows,
scheduling_state,
target_lag,
warehouse
FROM snowflake.tables.dynamic_tables
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

Create a dynamic table, with standard create modifiers as query parameters. See the Dynamic Table component definition for what is required to be provided in the request body.

INSERT INTO snowflake.tables.dynamic_tables (
name,
kind,
columns,
target_lag,
refresh_mode,
initialize,
warehouse,
cluster_by,
query,
data_retention_time_in_days,
max_data_extension_time_in_days,
comment,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ name }}' /* required */,
'{{ kind }}',
'{{ columns }}',
'{{ target_lag }}' /* required */,
'{{ refresh_mode }}',
'{{ initialize }}',
'{{ warehouse }}' /* required */,
'{{ cluster_by }}',
'{{ query }}' /* required */,
{{ data_retention_time_in_days }},
{{ max_data_extension_time_in_days }},
'{{ comment }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
RETURNING
status
;

DELETE examples

Delete a dynamic table with the given name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful.

DELETE FROM snowflake.tables.dynamic_tables
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

Create a new dynamic table by cloning from the specified resource

EXEC snowflake.tables.dynamic_tables.clone
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required,
@createMode='{{ createMode }}',
@copyGrants={{ copyGrants }},
@targetDatabase='{{ targetDatabase }}',
@targetSchema='{{ targetSchema }}'
@@json=
'{
"name": "{{ name }}",
"target_lag": "{{ target_lag }}",
"warehouse": "{{ warehouse }}",
"point_of_time": "{{ point_of_time }}"
}'
;