schemas
Creates, updates, deletes, gets or lists a schemas
resource.
Overview
Name | schemas |
Type | Resource |
Id | snowflake.schema.schemas |
Fields
Name | Datatype | Description |
---|---|---|
name | string | A Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. |
budget | string | Budget that defines a monthly spending limit on the compute costs for a Snowflake account or a custom group of Snowflake objects. |
comment | string | Optional comment in which to store information related to the schema. |
created_on | string | Date and time the schema was created. |
data_retention_time_in_days | integer | Number of days for which Time Travel actions (CLONE and UNDROP) can be performed on the schema, as well as specifying the default Time Travel retention time for all tables created in the schema |
database_name | string | Database that the schema belongs to |
default_ddl_collation | string | Specifies a default collation specification for all tables added to the schema. You an override the default at the schema and individual table levels. |
dropped_on | string | Date and time the schema was dropped. |
is_current | boolean | Current schema for the session. |
is_default | boolean | Default schema for a user. |
kind | string | Schema type, permanent (default) or transient. |
log_level | string | Severity level of messages that should be ingested and made available in the active event table. Currently, Snowflake supports only TRACE , DEBUG , INFO , WARN , ERROR , FATAL and OFF . |
managed_access | boolean | Whether this schema is a managed access schema that centralizes privilege management with the schema owner. |
max_data_extension_time_in_days | integer | Maximum number of days for which Snowflake can extend the data retention period for tables in the schema to prevent streams on the tables from becoming stale. |
options | string | |
owner | string | Name of the role that owns the schema. |
owner_role_type | string | Type of role that owns the object, either ROLE or DATABASE_ROLE . |
pipe_execution_paused | boolean | Whether pipe execution is paused. |
retention_time | integer | Number of days that historical data is retained for Time Travel. |
serverless_task_max_statement_size | string | Specifies the maximum allowed warehouse size for the serverless task. Minimum XSMALL, Maximum XXLARGE. |
serverless_task_min_statement_size | string | Specifies the minimum allowed warehouse size for the serverless task. Minimum XSMALL, Maximum XXLARGE. |
suspend_task_after_num_failures | integer | Specifies the number of consecutive failed task runs after which the current task is suspended automatically. |
trace_level | string | How trace events are ingested into the event table. Currently, Snowflake supports only ALWAYS , ON_EVENT , and OFF . |
user_task_managed_initial_warehouse_size | string | Size of the compute resources to provision for the first run of the serverless task, before a task history is available for Snowflake to determine an ideal size. |
user_task_timeout_ms | integer | Time limit, in milliseconds, for a single run of the task before it times out. |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
fetch_schema | SELECT | database_name, name, endpoint | Fetches a schema. |
list_schemas | SELECT | database_name, endpoint | Lists the accessible schemas. |
create_schema | INSERT | database_name, data__name, endpoint | Creates a schema, with modifiers as query parameters. You must provide the full schema definition when creating a schema. |
delete_schema | DELETE | database_name, name, endpoint | Deletes the specified schema. If you enable the ifExists parameter, the operation succeeds even if the schema does not exist. Otherwise, a 404 failure is returned if the schema does not exist. if the drop is unsuccessful. |
create_or_alter_schema | REPLACE | database_name, name, data__name, endpoint | Creates a new, or alters an existing, schema. You must provide the full schema definition even when altering an existing schema. |
clone_schema | EXEC | database_name, name, endpoint | Clones an existing schema, with modifiers as query parameters. You must provide the full schema definition when cloning an existing schema. |
undrop_schema | EXEC | database_name, name, endpoint | Undrops schema. |
SELECT
examples
Lists the accessible schemas.
SELECT
name,
budget,
comment,
created_on,
data_retention_time_in_days,
database_name,
default_ddl_collation,
dropped_on,
is_current,
is_default,
kind,
log_level,
managed_access,
max_data_extension_time_in_days,
options,
owner,
owner_role_type,
pipe_execution_paused,
retention_time,
serverless_task_max_statement_size,
serverless_task_min_statement_size,
suspend_task_after_num_failures,
trace_level,
user_task_managed_initial_warehouse_size,
user_task_timeout_ms
FROM snowflake.schema.schemas
WHERE database_name = '{{ database_name }}'
AND endpoint = '{{ endpoint }}';
INSERT
example
Use the following StackQL query and manifest file to create a new schemas
resource.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO snowflake.schema.schemas (
data__name,
data__kind,
data__comment,
data__managed_access,
data__data_retention_time_in_days,
data__default_ddl_collation,
data__log_level,
data__pipe_execution_paused,
data__max_data_extension_time_in_days,
data__suspend_task_after_num_failures,
data__trace_level,
data__user_task_managed_initial_warehouse_size,
data__serverless_task_min_statement_size,
data__serverless_task_max_statement_size,
data__user_task_timeout_ms,
database_name,
endpoint
)
SELECT
'{{ name }}',
'{{ kind }}',
'{{ comment }}',
'{{ managed_access }}',
'{{ data_retention_time_in_days }}',
'{{ default_ddl_collation }}',
'{{ log_level }}',
'{{ pipe_execution_paused }}',
'{{ max_data_extension_time_in_days }}',
'{{ suspend_task_after_num_failures }}',
'{{ trace_level }}',
'{{ user_task_managed_initial_warehouse_size }}',
'{{ serverless_task_min_statement_size }}',
'{{ serverless_task_max_statement_size }}',
'{{ user_task_timeout_ms }}',
'{{ database_name }}',
'{{ endpoint }}'
;
/*+ create */
INSERT INTO snowflake.schema.schemas (
data__name,
database_name,
endpoint
)
SELECT
'{{ name }}',
'{{ database_name }}',
'{{ endpoint }}'
;
- name: schemas
props:
- name: database_name
value: string
- name: data__name
value: string
- name: endpoint
value: string
- name: name
value: string
- name: kind
value: string
- name: comment
value: string
- name: managed_access
value: boolean
- name: data_retention_time_in_days
value: integer
- name: default_ddl_collation
value: string
- name: log_level
value: string
- name: pipe_execution_paused
value: boolean
- name: max_data_extension_time_in_days
value: integer
- name: suspend_task_after_num_failures
value: integer
- name: trace_level
value: string
- name: user_task_managed_initial_warehouse_size
value: string
- name: serverless_task_min_statement_size
value: string
- name: serverless_task_max_statement_size
value: string
- name: user_task_timeout_ms
value: integer
REPLACE
example
Replaces all fields in the specified schemas
resource.
/*+ update */
REPLACE snowflake.schema.schemas
SET
name = '{{ name }}',
kind = '{{ kind }}',
comment = '{{ comment }}',
managed_access = true|false,
data_retention_time_in_days = '{{ data_retention_time_in_days }}',
default_ddl_collation = '{{ default_ddl_collation }}',
log_level = '{{ log_level }}',
pipe_execution_paused = true|false,
max_data_extension_time_in_days = '{{ max_data_extension_time_in_days }}',
suspend_task_after_num_failures = '{{ suspend_task_after_num_failures }}',
trace_level = '{{ trace_level }}',
user_task_managed_initial_warehouse_size = '{{ user_task_managed_initial_warehouse_size }}',
serverless_task_min_statement_size = '{{ serverless_task_min_statement_size }}',
serverless_task_max_statement_size = '{{ serverless_task_max_statement_size }}',
user_task_timeout_ms = '{{ user_task_timeout_ms }}'
WHERE
database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND data__name = '{{ data__name }}'
AND endpoint = '{{ endpoint }}';
DELETE
example
Deletes the specified schemas
resource.
/*+ delete */
DELETE FROM snowflake.schema.schemas
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND endpoint = '{{ endpoint }}';