Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
318 changes: 293 additions & 25 deletions crates/lib-dialects/src/snowflake.rs

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions crates/lib-dialects/src/snowflake_keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CURRENT_TIMESTAMP
CURRENT_USER
DELETE
DISTINCT
DO
DROP
ELSE
EXISTS
Expand Down Expand Up @@ -50,6 +51,7 @@ MATCH_CONDITION
MINUS
NATURAL
NOT
NOTIFY
NULL
NULL_IF
OF
Expand All @@ -74,6 +76,7 @@ TABLESAMPLE
THEN
TO
TRIGGER
TRIGGERS
TRY_CAST
UNION
UNIQUE
Expand Down Expand Up @@ -173,6 +176,7 @@ CONTINUE
COPY
COPY_OPTIONS
CREDENTIALS
CREDIT_QUOTA
CROSS
CSV
CUBE
Expand All @@ -198,6 +202,7 @@ DATA_FORMAT
DATA_RETENTION_TIME_IN_DAYS
DATE
DATE_FORMAT
DAILY
DAYS_TO_EXPIRY
DEFAULT
DEFAULT_DDL_COLLATION
Expand Down Expand Up @@ -232,6 +237,7 @@ ENABLE_OCTAL
ENCODING
ENCRYPTION
END
END_TIMESTAMP
ENFORCED
ENFORCE_LENGTH
ENUM
Expand Down Expand Up @@ -265,6 +271,7 @@ FOREIGN
FORMAT
FORMATS
FORMAT_NAME
FREQUENCY
FUNCTION
FUNCTIONS
FUTURE
Expand All @@ -289,6 +296,7 @@ IF
IGNORE
IGNORE_UTF8_ERRORS
IMMEDIATE
IMMEDIATELY
IMMUTABLE
IMPORT
IMPORTS
Expand Down Expand Up @@ -353,12 +361,14 @@ MODEL
MODIFIED_AFTER
MODIFY
MONITOR
MONTHLY
MUST_CHANGE_PASSWORD
NAME
NAN
NETWORK
NEXT
NEXTVAL
NEVER
NO
NOCACHE
NOCYCLE
Expand All @@ -367,6 +377,7 @@ NOORDER
NOTIFICATION
NOTIFICATION_INTEGRATION
NOTIFICATION_PROVIDER
NOTIFY_USERS
NULLS
NULL_IF
OBJECT
Expand Down Expand Up @@ -400,6 +411,7 @@ PAST
PATTERN
FIELD_OPTIONALITY_ENCLOSED_BY
PER
PERCENT
PERMUTE
PIPE
PIPES
Expand Down Expand Up @@ -509,6 +521,7 @@ STAGE_COPY_OPTIONS
STAGE_FILE_FORMAT
STANDARD
STARTS
START_TIMESTAMP
STATEMENT
STATEMENT_QUEUED_TIMEOUT_IN_SECONDS
STATEMENT_TIMEOUT_IN_SECONDS
Expand All @@ -528,6 +541,7 @@ SUBPATH
SUPPORT
SUSPEND
SUSPENDED
SUSPEND_IMMEDIATE
SWAP
SYSDATE
SYSTEM
Expand Down Expand Up @@ -585,6 +599,7 @@ WAREHOUSE
WAREHOUSES
WAREHOUSE_SIZE
WAREHOUSE_TYPE
WEEKLY
WINDOW
WITH
WITHIN
Expand All @@ -594,5 +609,6 @@ WOY
WRAPPER
WRITE
XML
YEARLY
ZONE
ZSTD";
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ALTER ACCOUNT SET TIMEZONE = 'UTC';

ALTER ACCOUNT SET
ALLOW_ID_TOKEN = TRUE,
DEFAULT_DDL_COLLATION = 'en-ci',
CLIENT_ENCRYPTION_KEY_SIZE = 128,
NETWORK_POLICY = mypolicy
;

ALTER ACCOUNT UNSET TIMEZONE;
ALTER ACCOUNT UNSET DATA_RETENTION_TIME_IN_DAYS, JSON_INDENT;

ALTER ACCOUNT SET RESOURCE_MONITOR = VERY_RESTRICTIVE_MONITOR;

ALTER ACCOUNT SET PASSWORD POLICY mydb.security.at_least_twelve_characters;
ALTER ACCOUNT SET SESSION POLICY mydb.policies.only_one_hour;

ALTER ACCOUNT UNSET PASSWORD POLICY;
ALTER ACCOUNT UNSET SESSION POLICY;

ALTER ACCOUNT SET TAG
env = 'prod',
domain = 'sales'
;

ALTER ACCOUNT UNSET TAG env, domain;
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
file:
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: SET
- parameter: TIMEZONE
- comparison_operator:
- raw_comparison_operator: =
- quoted_literal: '''UTC'''
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: SET
- parameter: ALLOW_ID_TOKEN
- comparison_operator:
- raw_comparison_operator: =
- boolean_literal: 'TRUE'
- comma: ','
- parameter: DEFAULT_DDL_COLLATION
- comparison_operator:
- raw_comparison_operator: =
- quoted_literal: '''en-ci'''
- comma: ','
- parameter: CLIENT_ENCRYPTION_KEY_SIZE
- comparison_operator:
- raw_comparison_operator: =
- numeric_literal: '128'
- comma: ','
- parameter: NETWORK_POLICY
- comparison_operator:
- raw_comparison_operator: =
- naked_identifier: mypolicy
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: UNSET
- naked_identifier: TIMEZONE
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: UNSET
- naked_identifier: DATA_RETENTION_TIME_IN_DAYS
- comma: ','
- naked_identifier: JSON_INDENT
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: SET
- keyword: RESOURCE_MONITOR
- comparison_operator:
- raw_comparison_operator: =
- naked_identifier: VERY_RESTRICTIVE_MONITOR
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: SET
- keyword: PASSWORD
- keyword: POLICY
- table_reference:
- naked_identifier: mydb
- dot: .
- naked_identifier: security
- dot: .
- naked_identifier: at_least_twelve_characters
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: SET
- keyword: SESSION
- keyword: POLICY
- table_reference:
- naked_identifier: mydb
- dot: .
- naked_identifier: policies
- dot: .
- naked_identifier: only_one_hour
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: UNSET
- keyword: PASSWORD
- keyword: POLICY
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: UNSET
- keyword: SESSION
- keyword: POLICY
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: SET
- tag_equals:
- keyword: TAG
- tag_reference:
- naked_identifier: env
- comparison_operator:
- raw_comparison_operator: =
- quoted_literal: '''prod'''
- comma: ','
- tag_reference:
- naked_identifier: domain
- comparison_operator:
- raw_comparison_operator: =
- quoted_literal: '''sales'''
- statement_terminator: ;
- statement:
- keyword: ALTER
- keyword: ACCOUNT
- keyword: UNSET
- keyword: TAG
- tag_reference:
- naked_identifier: env
- comma: ','
- tag_reference:
- naked_identifier: domain
- statement_terminator: ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ALTER DATABASE mydb RENAME TO mydb2;
ALTER DATABASE IF EXISTS mydb RENAME TO mydb2;

ALTER DATABASE mydb SWAP WITH yourdb;
ALTER DATABASE IF EXISTS mydb SWAP WITH yourdb;

ALTER DATABASE mydb SET
DATA_RETENTION_TIME_IN_DAYS = 7,
MAX_DATA_EXTENSION_TIME_IN_DAYS = 14,
DEFAULT_DDL_COLLATION = 'en_ci',
COMMENT = 'My most excellent database'
;

ALTER DATABASE mydb SET TAG environment = 'test', billed_to = 'sales';

ALTER DATABASE mydb UNSET TAG environment, billed_to;

ALTER DATABASE mydb UNSET DATA_RETENTION_TIME_IN_DAYS, DEFAULT_DDL_COLLATION;
Loading
Loading