Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowflake: Add CREATE FILE FORMAT Support #3104

Merged
merged 17 commits into from May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
433 changes: 391 additions & 42 deletions src/sqlfluff/dialects/dialect_snowflake.py

Large diffs are not rendered by default.

41 changes: 40 additions & 1 deletion src/sqlfluff/dialects/dialect_snowflake_keywords.py
Expand Up @@ -55,6 +55,7 @@
NATURAL
NOT
NULL
NULL_IF
OF
ON
OR
Expand Down Expand Up @@ -100,6 +101,7 @@
ADD
ADMIN
AFTER
ALLOW_DUPLICATE
ALLOW_OVERLAPPING_EXECUTION
API
API_INTEGRATION
Expand All @@ -126,12 +128,17 @@
AZURE
AZURE_SAS_TOKEN
AZURE_TENANT_ID
BASE64
BEFORE
BEGIN
BERNOULLI
BINARY
BINARY_AS_TEXT
BINARY_FORMAT
BINDING
BLOCK
BROTLI
BZ2
CACHE
CALL
CALLED
Expand Down Expand Up @@ -179,6 +186,7 @@
DATA_RETENTION_TIME_IN_DAYS
DATABASES
DATE
DATE_FORMAT
DEFAULT
DEFAULT_DDL_COLLATION
DEFERRABLE
Expand All @@ -190,17 +198,23 @@
DESCRIBE
DIRECTORY
DISABLE
DISABLE_AUTO_CONVERT
DISABLE_SNOWFLAKE_DATA
DOMAIN
DOUBLE
ECONOMY
EMPTY
EMPTY_FIELD_AS_NULL
ENABLE
ENABLE_OCTAL
ENABLED
ENCODING
ENCRYPTION
END
ENFORCE_LENGTH
ENFORCED
ENUM
ERROR_ON_COLUMN_COUNT_MISMATCH
ESCAPE
EXCEPT
EXECUTE
Expand All @@ -210,7 +224,10 @@
EXTERNAL
EXTERNAL_STAGE
FETCH
FIELD_DELIMITER
FIELD_OPTIONALLY_ENCLOSED_BY
FILE
FILE_EXTENSION
FILE_FORMAT
FILES
FILTER
Expand All @@ -231,10 +248,12 @@
GROUPING
GZIP
HEADERS
HEX
HISTORY
IDENTITY
IF
IGNORE
IGNORE_UTF8_ERRORS
IMMEDIATE
IMMUTABLE
IMPORTED
Expand All @@ -259,6 +278,7 @@
LOCAL
LOCATION
LOCKS
LZO
M
MANAGE
MANAGED
Expand Down Expand Up @@ -295,6 +315,7 @@
NOORDER
NOTIFICATION
NOTIFICATION_INTEGRATION
NULL_IF
NULLS
OBJECT
OBJECTS
Expand Down Expand Up @@ -329,6 +350,7 @@
POLICY
PRECEDING
PRECISION
PRESERVE_SPACE
PRIMARY
PRIOR
PRIVILEGES
Expand All @@ -338,8 +360,10 @@
PURGE
QUERIES
RANGE
RAW_DEFLATE
READ
RECLUSTER
RECORD_DELIMITER
RECURSIVE
REFERENCE_USAGE
REFERENCES
Expand All @@ -350,6 +374,7 @@
RENAME
REPEATABLE
REPLACE
REPLACE_INVALID_CHARACTERS
REPLICATION
RESET
RESOURCE
Expand Down Expand Up @@ -394,7 +419,12 @@
SHOW_INITIAL_ROWS
SIZE_LIMIT
SKIP
SKIP_BLANK_LINES
SKIP_BYTE_ORDER_MARK
SKIP_FILE
SKIP_HEADER
SNAPPY
SNAPPY_COMPRESSION
SNOWFLAKE_FULL
SNOWFLAKE_SSE
SQL
Expand All @@ -416,6 +446,9 @@
STORAGE_PROVIDER
STREAM
STREAMS
STRIP_NULL_VALUES
STRIP_OUTER_ARRAY
STRIP_OUTER_ELEMENT
SUBPATH
SUSPEND
SUSPENDED
Expand All @@ -434,11 +467,14 @@
TERSE
TEXT
TIME
TIME_FORMAT
TIMESTAMP
TIMESTAMP_FORMAT
TOP
TRANSACTION
TRANSACTIONS
TRANSIENT
TRIM_SPACE
TRUNCATE
TRUNCATECOLUMNS
TYPE
Expand All @@ -456,6 +492,8 @@
USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE
USER_TASK_TIMEOUT_MS
USERS
UTF8
VALIDATE_UTF8
VALIDATION_MODE
VALUE
VARIABLES
Expand All @@ -478,4 +516,5 @@
WRAPPER
WRITE
XML
ZONE"""
ZONE
ZSTD"""
Expand Up @@ -3,7 +3,7 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 0358ab911af6b71a0be4d7af8cf4f370cd07e767576a85199ca407ced21de539
_hash: 1d7c2573a734efd0064283ccdf3e3034b30d01e841ceb3c597ec17f52ab29387
file:
- statement:
alter_function_statement:
Expand Down Expand Up @@ -108,7 +108,7 @@ file:
- keyword: COMPRESSION
- comparison_operator:
raw_comparison_operator: '='
- keyword: GZIP
- compression_type: GZIP
- statement_terminator: ;
- statement:
alter_function_statement:
Expand Down
72 changes: 39 additions & 33 deletions test/fixtures/dialects/snowflake/snowflake_copy_into_table.yml
Expand Up @@ -3,7 +3,7 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 9396e7c7b8f6c8cc368ede657010047edd1f6a4adf79ccbc184d23a4907170b9
_hash: bb01b4d7c0a76675c82caef4cd42bdce2e17d7dece694e1c9186b6ea5df962a6
file:
- statement:
copy_into_statement:
Expand All @@ -30,10 +30,11 @@ file:
- file_format_segment:
bracketed:
start_bracket: (
keyword: type
comparison_operator:
raw_comparison_operator: '='
file_type: csv
csv_file_format_type_parameters:
keyword: type
comparison_operator:
raw_comparison_operator: '='
file_type: csv
end_bracket: )
- statement_terminator: ;
- statement:
Expand Down Expand Up @@ -72,10 +73,11 @@ file:
- file_format_segment:
bracketed:
start_bracket: (
keyword: type
comparison_operator:
raw_comparison_operator: '='
file_type: "'CSV'"
csv_file_format_type_parameters:
keyword: type
comparison_operator:
raw_comparison_operator: '='
file_type: "'CSV'"
end_bracket: )
- keyword: pattern
- comparison_operator:
Expand Down Expand Up @@ -243,10 +245,11 @@ file:
- file_format_segment:
bracketed:
start_bracket: (
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
json_file_format_type_parameters:
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
end_bracket: )
- statement_terminator: ;
- statement:
Expand Down Expand Up @@ -278,10 +281,11 @@ file:
- file_format_segment:
bracketed:
start_bracket: (
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
json_file_format_type_parameters:
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
end_bracket: )
- statement_terminator: ;
- statement:
Expand All @@ -299,15 +303,15 @@ file:
- file_format_segment:
bracketed:
start_bracket: (
keyword: type
comparison_operator:
raw_comparison_operator: '='
file_type: csv
format_type_options_segment:
identifier: SKIP_HEADER
comparison_operator:
csv_file_format_type_parameters:
- keyword: type
- comparison_operator:
raw_comparison_operator: '='
- file_type: csv
- keyword: SKIP_HEADER
- comparison_operator:
raw_comparison_operator: '='
literal: '1'
- integer_segment: '1'
end_bracket: )
- statement_terminator: ;
- statement:
Expand All @@ -330,10 +334,11 @@ file:
- file_format_segment:
bracketed:
start_bracket: (
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
json_file_format_type_parameters:
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
end_bracket: )
- statement_terminator: ;
- statement:
Expand All @@ -356,9 +361,10 @@ file:
- file_format_segment:
bracketed:
start_bracket: (
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
json_file_format_type_parameters:
keyword: TYPE
comparison_operator:
raw_comparison_operator: '='
file_type: JSON
end_bracket: )
- statement_terminator: ;
Expand Up @@ -3,7 +3,7 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 3f0f12d9b8a24f90c42913f161066fea277e95f6c8eb6413885ffbb7ecde45fb
_hash: 9419529af7a78150df6722b8a13acb7d6226ceefbb06c70387503097afdfb4ff
file:
- statement:
create_external_function_statement:
Expand Down Expand Up @@ -89,7 +89,7 @@ file:
- keyword: COMPRESSION
- comparison_operator:
raw_comparison_operator: '='
- keyword: NONE
- compression_type: NONE
- keyword: REQUEST_TRANSLATOR
- comparison_operator:
raw_comparison_operator: '='
Expand Down Expand Up @@ -169,7 +169,7 @@ file:
- keyword: COMPRESSION
- comparison_operator:
raw_comparison_operator: '='
- keyword: NONE
- compression_type: NONE
- keyword: REQUEST_TRANSLATOR
- comparison_operator:
raw_comparison_operator: '='
Expand Down Expand Up @@ -252,7 +252,7 @@ file:
- keyword: COMPRESSION
- comparison_operator:
raw_comparison_operator: '='
- keyword: NONE
- compression_type: NONE
- keyword: REQUEST_TRANSLATOR
- comparison_operator:
raw_comparison_operator: '='
Expand Down