Repository navigation
test(compliance): add portability rungs M7 (window ORDER BY) and M8 (ratio-to-total) - #700
Conversation
6e4e8f5 to
e6715ce
Compare
…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>
e6715ce to
d29f031
Compare
christianeu-db
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
Agreed, renamed to prior_order_amount in #775, in the fixture and in manifest.yaml.
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.ORDER BY:LAG(amount) OVER (ORDER BY order_date), a runningSUMwithROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, andRANK() OVER (ORDER BY amount DESC)withoutNULLS FIRST/NULLS LAST, which relies on the #587 default. Authored inOSSIE_SQL_2026, the dialect that default applies tom7/m7_window_order.ossie.yamlORDER BY:amount / SUM(amount) OVER ()andamount / SUM(amount) OVER (PARTITION BY region), the "Percent of total" form inexpression_language.mdm8/m8_ratio_to_total.ossie.yamlBoth 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.mdleaves where window functions are allowed to the query interface. That interface (#653,wide_table_semantics.mdSection 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
validation/validate.pyagainst the 0.3.0.dev0 schema, no warnings.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.