Schema
Snowflake Docs - CREATE SCHEMA
Snowflake Docs - ALTER SCHEMA
Usage
- Each folder within a Database folder represents a schema
- Schema name = folder name of schema
- Config file in "schema.yml" within schema name folder
Snowflake Attributes
Parameter |
Description |
|---|---|
DATA_RETENTION_TIME_IN_DAYS |
(Int) - Optional |
COMMENT |
(String) - Optional |
OWNER |
(String) - Optional
|
TAGS |
({KEY:VALUE}) - Optional |
GRANTS |
({KEY:VALUE}) - Optional |
Optional Parameter Defaults - if omitted, Snowflake defaults for parameters are used, just like creating an object manually.
Deployment attributes
Parameter |
Description |
|---|---|
DEPLOY_ENV |
(List) - Optional
|
DEPLOY_LOCK |
(Bool) - Optional
|
Folder Structure
snowflake/data/[database name]/[schema name]/schema.yml
Example Structure
snowflake/data/MY_DATABASE1/HR/schema.yml
snowflake/data/MY_DATABASE1/ACCOUNTING/schema.yml
This creates 2 schemas named "HR" and "ACCOUNT" within database "MY_DATABASE1", each with their own schema.yml file within their respected folder
Samples
Basic
COMMENT: This is the comment on a schema
OWNER: INSTANCEADMIN
DATA_RETENTION_TIME_IN_DAYS: 1
TAGS:
- {{ref('CONTROL__GOVERNANCE__ENV')}}: PROD
- {{ref('CONTROL__GOVERNANCE__ZONE')}}: ANALYTICS
GRANTS:
- {{role('SOME_ROLE')}}: USAGE
With a deploy lock & restricted deployment environments.
COMMENT: {{var_from_env_config}}
OWNER: INSTANCEADMIN
TAGS:
- {{ref('CONTROL__GOVERNANCE__ENV')}}: PROD
- {{ref('CONTROL__GOVERNANCE__ZONE')}}: ANALYTICS
GRANTS:
- {{role('SOME_ROLE')}}: USAGE
DEPLOY_LOCK: true
DEPLOY_ENV:
- PROD
- TEST