Skip to content

fix(compliance): read window NULL placement in the grader as the authored dialect means it - #756

Merged
jbonofre merged 1 commit into
apache:mainfrom
MrBlack1995:fix/grader-window-null-ordering
Nov 18, 2026
Merged

jbonofre merged 1 commit into
apache:mainfrom
MrBlack1995:fix/grader-window-null-ordering

Conversation

@MrBlack1995

@MrBlack1995 MrBlack1995 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The grader read an omitted NULL placement in a window ORDER BY the opposite way from the spec. Split out of #700 so the fix can be reviewed on its own; the M7 and M8 fixtures stay in #700.

It normalizes expressions with sqlglot's base dialect, which sorts NULL as the smallest value. So for RANK() OVER (ORDER BY amount DESC) it graded a converter returning ... DESC NULLS LAST, which moves the NULL rows from first to last, as a cosmetic rewrite, and the equivalent ... DESC NULLS FIRST as needing review. It is the same reading #587 describes for the SQLGlot-based converters. The grader now picks the NULL ordering from the authored tag:

Nothing else changes in how expressions are compared.

Validation

  • The compliance tests pass (53) on current main. Three new tests check that an explicit default is cosmetic and a flipped placement needs review in OSSIE_SQL_2026, and that in ANSI_SQL neither explicit placement is proven equal to an omitted one. They fail without the fix.
  • I graded the 120 portability cases of the latest Interop matrix run on apache/ossie-converters main (run 44250491430) with main's grader and with this one: every finding is the same. The matrix has no window expressions yet, so the change shows once M7 is graded there.

Related Issues

Refs apache/ossie-converters#24. Uses the default from #587. Companion to #700 (M7 and M8); the two do not conflict.

…ored dialect means it

sqlglot's base dialect sorts NULL as the smallest value, the opposite of
the OSSIE_SQL_2026 default (apache#587). The grader therefore marked
RANK() OVER (ORDER BY x DESC NULLS LAST), which changes the order, as a
cosmetic rewrite of RANK() OVER (ORDER BY x DESC), and the equivalent
DESC NULLS FIRST as needing review. OSSIE_SQL_2026 expressions are now
compared with NULL as the largest value; ANSI_SQL ones, whose default is
the engine's, only count as cosmetic when equal under both orderings.

Co-authored-by: Isaac <no-reply@databricks.com>
@jbonofre
jbonofre force-pushed the fix/grader-window-null-ordering branch from a54e83e to 31914e3 Compare November 18, 2026 21:48

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for splitting this out and adding the tests.

Using NULL_ORDERING = "nulls_are_large" for OSSIE_SQL_2026 alignes the grader with core-spec/expression_language.md (#587), so explicit default placements (DESC NULLS FIRST, ASC NULLS LAST) are treated as cosmetic while flipped ones are flagged for review.
Also, comparing ANSI_SQL under both nulls_are_small and nulls_are_large cleanly avoids false cosmetic matches between omitted and explicit placements while keeping genuine spelling rewrites (such as column qualification) cosmetic.

I rebased from main after #757.

@jbonofre
jbonofre merged commit f0e29bf into apache:main Nov 18, 2026
4 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.

2 participants