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): generate LIMIT when OFFSET exists #4575 #4581

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

geooo109
Copy link
Collaborator

@geooo109 geooo109 commented Jan 8, 2025

Fixes snowflake problem #4575

This PR allows the generation of snowflake queries when the OFFSET is present in the input dialect without a LIMIT.

Based on the snowflake's doc, an OFFSET must always match with a LIMIT. Based on the discussion here, a LIMIT NULL can be inserted into the query in order to be parsed correctly.

Example:

>>> sqlglot.transpile("SELECT 1 ORDER BY 1 OFFSET 0", read="trino", write="snowflake")
['SELECT 1 ORDER BY 1 LIMIT NULL OFFSET 0']

Docs
Snowflake LIMIT

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if this fix is only relevant to Snowflake.

sqlglot/dialects/snowflake.py Outdated Show resolved Hide resolved
@georgesittas georgesittas merged commit d250846 into main Jan 9, 2025
8 checks passed
@georgesittas georgesittas deleted the snowflake_offset branch January 9, 2025 08:45
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.

2 participants