Skip to content

test(compliance): add portability rungs M7 (window ORDER BY) and M8 (ratio-to-total) - #700

Merged
christianeu-db merged 2 commits into
apache:mainfrom
MrBlack1995:test/portability-m7-m8
Nov 19, 2026
Merged

christianeu-db merged 2 commits into
apache:mainfrom
MrBlack1995:test/portability-m7-m8

Conversation

@MrBlack1995

@MrBlack1995 MrBlack1995 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #631: the two rungs held for the default NULL placement in window ORDER BY, now that #587 has settled it. This PR adds the fixtures only. The grader fix that reads that default the way the spec defines it is now its own PR, so each can be reviewed on its own.

Rung Construct Fixture
M7 window functions with an ORDER BY: LAG(amount) OVER (ORDER BY order_date), a running SUM with ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, and RANK() OVER (ORDER BY amount DESC) without NULLS FIRST/NULLS LAST, which relies on the #587 default. Authored in OSSIE_SQL_2026, the dialect that default applies to m7/m7_window_order.ossie.yaml
M8 ratio-to-total with no ORDER BY: amount / SUM(amount) OVER () and amount / SUM(amount) OVER (PARTITION BY region), the "Percent of total" form in expression_language.md m8/m8_ratio_to_total.ossie.yaml

Both rungs test field expressions over sibling columns of their dataset, like M1, so they carry one fixture each. manifest.yaml, the identity test and both READMEs now list M0-M8, and the note that M7 and M8 wait for #587 is gone.

Why field expressions. expression_language.md leaves where window functions are allowed to the query interface. That interface (#653, wide_table_semantics.md Section 5.2) defers window functions in model-scoped metrics (E_DEFERRED_WINDOWED_METRIC) and puts no such limit on field expressions, so both rungs place their windows in fields.

Validation

  • All 15 fixtures pass validation/validate.py against the 0.3.0.dev0 schema, no warnings.
  • The compliance tests pass (50) on current main. The identity test runs M0-M8 through a no-op converter and every element grades PORTABLE, with or without the grader fix. The manifest tests find every M7 and M8 element under the grader's own key.

Related Issues

Refs apache/ossie-converters#24 (portability measurement). Follows #631; uses the default from #587. The grader's reading of that default is fixed separately in #756.

MrBlack1995 and others added 2 commits November 18, 2026 07:38
…ratio-to-total)

M7 covers window functions with an ORDER BY: LAG, a running SUM with a
ROWS frame, and RANK() OVER (ORDER BY ... DESC) without NULLS FIRST/LAST,
which relies on the OSSIE_SQL_2026 default from apache#587. That default is
defined for OSSIE_SQL_2026 only, so M7 is authored in it. M8 covers
ratio-to-total, x / SUM(x) OVER () and OVER (PARTITION BY ...), with no
ORDER BY. Both are field expressions over sibling columns, as M1.

The manifest, the identity test and both READMEs list M0-M8; the hold
note on apache#587 is gone. All 15 fixtures validate on main (f28692a) with
sqlglot 30.21.0.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@christianeu-db christianeu-db left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks @MrBlack1995! Left two small notes; feel free to address them here or as follow-ups.

expression:
dialects:
- dialect: OSSIE_SQL_2026
expression: LAG(amount) OVER (ORDER BY order_date)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LAG and the running SUM also rely on the #587 default (NULLS LAST for ASC, which four engines in the spec's table don't give natively), so losing it shows up on all three M7 elements, not only amount_rank. Could these two say ORDER BY order_date NULLS LAST, like the spec's RANK() example, so only the rank tests the default? Or, if that's intended, the manifest could say all three rely on it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, the default was under test three times. Done in #775: LAG and the running SUM now write ORDER BY order_date NULLS LAST, so only amount_rank relies on the default.

- dialect: OSSIE_SQL_2026
expression: order_date
datatype: Date
- name: prior_day_amount

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: LAG(amount) OVER (ORDER BY order_date) returns the previous order's amount, which can be from the same day:

order_date  amount  prior_day_amount
2026-01-01  10      NULL
2026-01-02  20      10
2026-01-02  30      20

Could we name it prior_order_amount (here and in manifest.yaml)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, renamed to prior_order_amount in #775, in the fixture and in manifest.yaml.

@christianeu-db
christianeu-db merged commit 7bfe21c into apache:main Nov 19, 2026
7 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