dynamic_tables
Creates, updates, deletes, gets or lists a dynamic_tables
resource.
Overview
Name | dynamic_tables |
Type | Resource |
Id | snowflake.dynamic_table.dynamic_tables |
Fields
Name | Datatype | Description |
---|---|---|
name | string | Specifies the name for the dynamic table, must be unique for the schema in which the dynamic table is created |
automatic_clustering | boolean | If Automatic Clustering is enabled for your account, specifies whether it is explicitly enabled or disabled for the dynamic table. |
budget | string | Name of the budget if the object is monitored by a budget |
bytes | integer | 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_by | array | Specifies one or more columns or column expressions in the dynamic table as the clustering key |
columns | array | |
comment | string | Specifies a comment for the dynamic table. |
created_on | string | Date and time when the dynamic table was created. |
data_retention_time_in_days | integer | Specifies the retention period for the dynamic table so that Time Travel actions (SELECT, CLONE) can be performed on historical data in the dynamic table |
database_name | string | Database in which the dynamic table is stored |
initialize | string | Specifies the behavior of the initial refresh of the dynamic table |
kind | string | Specifies the dynamic table type, permanent (default) or transient. |
max_data_extension_time_in_days | integer | Specifies the retention period for the dynamic table so that Time Travel actions (SELECT, CLONE) can be performed on historical data in the dynamic table |
owner | string | Role that owns the table |
owner_role_type | string | The type of role that owns the object. |
query | string | Specifies the query whose results the dynamic table should contain |
refresh_mode | string | Specifies the refresh type for the dynamic table |
rows | integer | Number of rows in the dynamic table. |
scheduling_state | string | Scheduling state (RUNNING or SUSPENDED) |
schema_name | string | Schema in which the dynamic table is stored |
target_lag | object | Specifies the schedule for periodically refreshing the dynamic table. |
warehouse | string | Specifies the name of the warehouse that provides the compute resources for refreshing the dynamic table |
Methods
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
fetch_dynamic_table | SELECT | database_name, name, schema_name, endpoint | - | Fetch a Dynamic Table. |
list_dynamic_tables | SELECT | database_name, schema_name, endpoint | like , startsWith , showLimit , fromName , deep | Lists the dynamic tables under the database and schema. |
create_dynamic_table | INSERT | database_name, schema_name, data__name, data__query, data__target_lag, data__warehouse, endpoint | createMode | 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. |
delete_dynamic_table | DELETE | database_name, name, schema_name, endpoint | ifExists | 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. |
clone_dynamic_table | EXEC | database_name, name, schema_name, data__name, endpoint | createMode , copyGrants , targetDatabase , targetSchema | Create a new dynamic table by cloning from the specified resource |
refresh_dynamic_table | EXEC | database_name, name, schema_name, endpoint | ifExists | Specifies that the dynamic table should be manually refreshed |
resume_dynamic_table | EXEC | database_name, name, schema_name, endpoint | ifExists | Resume refreshes on the dynamic table |
resume_recluster_dynamic_table | EXEC | database_name, name, schema_name, endpoint | ifExists | Resume recluster of a dynamic table |
suspend_dynamic_table | EXEC | database_name, name, schema_name, endpoint | ifExists | Suspend refreshes on the dynamic table |
suspend_recluster_dynamic_table | EXEC | database_name, name, schema_name, endpoint | ifExists | Suspend recluster of a dynamic table |
swap_with_dynamic_table | EXEC | database_name, name, schema_name, targetName, endpoint | ifExists , targetDatabase , targetSchema | Swap with another dynamic table |
undrop_dynamic_table | EXEC | database_name, name, schema_name, endpoint | - | Undrop specified dynamic table |
Optional Parameter Details
Name | Description | Type | Default |
---|---|---|---|
copyGrants | Query parameter to enable copy grants when creating the object. | boolean | false |
createMode | Query 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. | string | errorIfExists |
deep | Optionally includes dependency information of the dynamic table. | boolean | - |
fromName | Query 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 | - |
ifExists | Query 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. | boolean | false |
like | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. | string | - |
showLimit | Query parameter to limit the maximum number of rows returned by a command. | integer | - |
startsWith | Query 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 | - |
targetDatabase | Database of the newly created dynamic table. Defaults to the source table's database. | string | - |
targetSchema | Schema of the newly created dynamic table. Defaults to the source table's schema. | string | - |
SELECT
examples
Lists the dynamic tables under the database and schema.
SELECT
name,
automatic_clustering,
budget,
bytes,
cluster_by,
columns,
comment,
created_on,
data_retention_time_in_days,
database_name,
initialize,
kind,
max_data_extension_time_in_days,
owner,
owner_role_type,
query,
refresh_mode,
rows,
scheduling_state,
schema_name,
target_lag,
warehouse
FROM snowflake.dynamic_table.dynamic_tables
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 dynamic_tables
resource.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO snowflake.dynamic_table.dynamic_tables (
data__name,
data__kind,
data__columns,
data__target_lag,
data__refresh_mode,
data__initialize,
data__warehouse,
data__cluster_by,
data__query,
data__data_retention_time_in_days,
data__max_data_extension_time_in_days,
data__comment,
database_name,
schema_name,
endpoint
)
SELECT
'{{ 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 }}'
;
/*+ create */
INSERT INTO snowflake.dynamic_table.dynamic_tables (
data__name,
data__target_lag,
data__warehouse,
data__query,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ target_lag }}',
'{{ warehouse }}',
'{{ query }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
- name: dynamic_tables
props:
- name: database_name
value: string
- name: schema_name
value: string
- name: data__name
value: string
- name: data__query
value: string
- name: data__target_lag
value: string
- name: data__warehouse
value: string
- name: endpoint
value: string
- name: name
value: string
- name: kind
value: string
- name: columns
value: array
props:
- name: name
value: string
- name: datatype
value: string
- name: comment
value: string
- name: target_lag
props:
- name: type
value: string
- name: refresh_mode
value: string
- name: initialize
value: string
- name: warehouse
value: string
- name: cluster_by
value: array
- name: query
value: string
- name: data_retention_time_in_days
value: integer
- name: max_data_extension_time_in_days
value: integer
- name: comment
value: string
DELETE
example
Deletes the specified dynamic_tables
resource.
/*+ delete */
DELETE FROM snowflake.dynamic_table.dynamic_tables
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';