Skip to content

Commit

Permalink
Fix(snowflake): make FILE_FORMAT option always be uppercase in COPY INTO
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas committed May 4, 2024
1 parent b77709e commit fc979a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sqlglot/dialects/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,8 @@ def struct_sql(self, expression: exp.Struct) -> str:
return self.func("OBJECT_CONSTRUCT", *flatten(zip(keys, values)))

def copyparameter_sql(self, expression: exp.CopyParameter) -> str:
option = self.sql(expression, "this")
if option.upper() == "FILE_FORMAT":
option = self.sql(expression, "this").upper()
if option == "FILE_FORMAT":
values = self.expressions(expression, key="expression", flat=True, sep=" ")
return f"{option} = ({values})"

Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,7 @@ def test_try_cast(self):

def test_copy(self):
self.validate_identity(
"""COPY INTO mytable (col1, col2) FROM 's3://mybucket/data/files' FILES = ('file1', 'file2') PATTERN = 'pattern' file_format = (FORMAT_NAME = my_csv_format NULL_IF = ('str1', 'str2')) PARSE_HEADER = TRUE""",
"""COPY INTO mytable (col1, col2) FROM 's3://mybucket/data/files' FILES = ('file1', 'file2') PATTERN = 'pattern' FILE_FORMAT = (FORMAT_NAME = my_csv_format NULL_IF = ('str1', 'str2')) PARSE_HEADER = TRUE"""
)
self.validate_identity(
Expand Down

0 comments on commit fc979a0

Please sign in to comment.