Skip to content

Conversation

NandanaRaol
Copy link
Contributor

This pull request refines the _as_sql_window method in mssql/compiler.py to improve clarity, ensure correctness, and enhance support for SQL window functions. Key changes include adding detailed comments, handling edge cases for ORDER BY, and improving the formatting of the final SQL statement.

Enhancements to _as_sql_window method:

  • Enhanced handling of SQL clauses:
    • Added logic to handle cases where order_by compiles to an empty string by defaulting to ORDER BY (SELECT NULL).
    • Ensured proper compilation of PARTITION BY, ORDER BY, and frame clauses with detailed comments for better maintainability. [1] [2]

@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 15:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the _as_sql_window method to handle empty or missing ORDER BY clauses by defaulting to ORDER BY (SELECT NULL), adds detailed inline comments for each SQL clause, and refines the formatting of the final window SQL statement.

  • Default to ORDER BY (SELECT NULL) when order_by is missing or compiles to an empty string
  • Added step-by-step comments for expression support, partitioning, ordering, and framing
  • Streamlined template selection and SQL formatting
Comments suppressed due to low confidence (1)

mssql/compiler.py:156

  • New fallback logic for empty or missing ORDER BY is introduced here; consider adding unit tests to verify behavior when order_by is None and when it compiles to an empty string.
# Handle ORDER BY clause if present.

@bewithgaurav bewithgaurav changed the title FEAT:Support 5.1-Handled empty order-by clause by defaulting it to SELECT NULL FEAT: Support 5.1 - Handled empty order-by clause by defaulting it to SELECT NULL Jun 11, 2025
@NandanaRaol NandanaRaol merged commit b2b1234 into dev Jun 16, 2025
41 of 50 checks passed
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.

3 participants