Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@max-sixty
Copy link
Member

Summary

  • Adds ORDER BY 1 fallback for Snowflake window functions when no explicit sort is specified
  • Snowflake requires an ORDER BY clause for ranking functions like ROW_NUMBER()
  • Adds requires_order_by_in_window_function() method to DialectHandler trait

Fixes #5580

Test plan

  • Added test_snowflake_row_number_requires_order_by - verifies ORDER BY 1 is added when no sort specified
  • Added test_snowflake_row_number_with_explicit_sort - verifies user-provided sort is preserved
  • Verified other dialects (PostgreSQL, DuckDB, Generic, MySQL) are unaffected
  • All 616 tests passing locally

🤖 Generated with Claude Code

Snowflake requires an ORDER BY clause for ranking window functions like
ROW_NUMBER(). This adds `ORDER BY 1` as a fallback when no explicit sort
is specified.

Fixes PRQL#5580

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@max-sixty max-sixty merged commit 88649bd into PRQL:main Nov 29, 2025
35 checks passed
@max-sixty max-sixty deleted the snowflake branch November 29, 2025 18:31
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.

Invalid ROW_NUMBER() OVER clause generated for Snowflake

1 participant