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

Query with OFFSET statement without LIMIT in Trino get translated into invalid query in Snowflake #4575

Closed
baruchoxman opened this issue Jan 7, 2025 · 0 comments · Fixed by #4589
Assignees

Comments

@baruchoxman
Copy link

baruchoxman commented Jan 7, 2025

Way to reproduce:

>>> a = sqlglot.parse_one("SELECT 1 ORDER BY 1 OFFSET 0", "trino")
>>> a.sql("snowflake")
'SELECT 1 ORDER BY 1 OFFSET 0'

The resulting query is not valid in Snowflake:
image

Also, the parsing of the following fails, while being valid in Trino:

>>> a = sqlglot.parse_one("SELECT 1 OFFSET 0", "trino")
...
sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 1, Col: 17.
  SELECT 1 OFFSET 0

https://trino.io/docs/current/sql/select.html#offset-clause

@baruchoxman baruchoxman changed the title Queries with OFFSET statement without LIMIT in Trino get translated into invalid queries in Snowflake Queries with OFFSET statement without LIMIT in Trino get translated into invalid query in Snowflake Jan 7, 2025
@baruchoxman baruchoxman changed the title Queries with OFFSET statement without LIMIT in Trino get translated into invalid query in Snowflake Query with OFFSET statement without LIMIT in Trino get translated into invalid query in Snowflake Jan 7, 2025
@geooo109 geooo109 self-assigned this Jan 8, 2025
georgesittas added a commit that referenced this issue Jan 9, 2025
* fix(snowflake): generate LIMIT when OFFSET exists

* PR feedback 1

Co-authored-by: Jo <[email protected]>

* PR feedback 1 (change snowflake test)

---------

Co-authored-by: Jo <[email protected]>
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 a pull request may close this issue.

2 participants