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

fix(snowflake): COPY postfix #3398

Merged
merged 4 commits into from
May 3, 2024
Merged

fix(snowflake): COPY postfix #3398

merged 4 commits into from
May 3, 2024

Conversation

VaggelisD
Copy link
Collaborator

@VaggelisD VaggelisD commented May 2, 2024

Fixes #3388

Design notes

  • Snowflake's FILE_PARAM option is now parsed & generated on its own to accommodate for the optional formatTypeOptions that might come after the TYPE opts:
FILE_FORMAT = (  
 FORMAT_NAME = '[<namespace>.]<file_format_name>' | 
 TYPE = { CSV | ... | XML } [ formatTypeOptions ] 
) 
  • Allowed parse_primary() to parse expressions such as NULL_IF = () into empty tuples. That would otherwise try to be parsed in an exp.Paren with no expression, which would throw an error

  • Refactored the file parsing to also include Snowflake's @external_file syntax besides strings

  • Added the issue query and other Snowflake doc examples as test cases

Docs

sqlglot/generator.py Outdated Show resolved Hide resolved
@georgesittas
Copy link
Collaborator

Will review as well shortly

sqlglot/dialects/snowflake.py Outdated Show resolved Hide resolved
sqlglot/dialects/snowflake.py Outdated Show resolved Hide resolved
sqlglot/parser.py Show resolved Hide resolved
sqlglot/parser.py Show resolved Hide resolved
sqlglot/parser.py Show resolved Hide resolved
sqlglot/dialects/snowflake.py Outdated Show resolved Hide resolved
sqlglot/generator.py Outdated Show resolved Hide resolved
@georgesittas
Copy link
Collaborator

Thanks for addressing comments @VaggelisD 👍

@georgesittas georgesittas merged commit 2c2a788 into main May 3, 2024
5 checks passed
@georgesittas georgesittas deleted the vaggelisd/copy_postfix branch May 3, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version 23.12.2 fails to parse some COPY clauses
3 participants