Skip to content

test(compliance): add an M5 variant that composes through AGG(dataset.metric) - #758

Merged
christianeu-db merged 1 commit into
apache:mainfrom
MrBlack1995:test/portability-m5-agg
Nov 23, 2026
Merged

christianeu-db merged 1 commit into
apache:mainfrom
MrBlack1995:test/portability-m5-agg

Conversation

@MrBlack1995

@MrBlack1995 MrBlack1995 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The follow-up suggested in the #631 review: an M5 variant that tests real composition. Since #703 a model-scoped metric may evaluate a dataset-scoped metric with AGG(dataset.metric) (core-spec/spec.md, Metric Scoping rule 6), so M5.agg_ref composes the same avg_order_value that way:

datasets:
  - name: sales
    metrics:
      - {name: total_amount, ... SUM(amount)}
      - {name: order_count,  ... COUNT(order_id)}
metrics:
  - name: avg_order_value
    ... AGG(sales.total_amount) / NULLIF(AGG(sales.order_count), 0)
  • Tagged OSSIE_SQL_2026, since AGG is defined there only. It keeps the primary's NULLIF, so both forms are NULL when there are no orders.
  • The inlined fixture stays the primary; the new one has the role composition-form. The M5 comment, the manifest construct and the README row now describe both.

Validation

  • m5_agg_ref.ossie.yaml passes validation/validate.py; replacing AGG(sales.total_amount) with AGG(sales.amount) fails with the validator's "names a field" error, so the fixture uses the rule as the validator enforces it. All 14 fixtures on this branch validate.
  • The compliance tests pass (51) on current main. The identity test grades every element of the new fixture PORTABLE. A new test pins that a converter which expands the AGG into the base metric's expression grades as review, since the grader cannot prove the two equal.
  • No grader change.

Related Issues

Follows #631 (suggested in its review) and #703. Refs apache/ossie-converters#24. Independent of #700, #756 and #757.

….metric)

Since apache#703 a model-scoped metric may evaluate a dataset-scoped metric with
AGG(dataset.metric). M5.agg_ref composes the same avg_order_value from two
dataset-scoped base metrics that way, tagged OSSIE_SQL_2026, next to the
inlined primary. A converter that expands the AGG grades as review.

Co-authored-by: Isaac <no-reply@databricks.com>
@MrBlack1995
MrBlack1995 force-pushed the test/portability-m5-agg branch from 3f5a7d3 to 7d5b0fa Compare November 19, 2026 05:27

@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! One note inline, fine as a follow-up.

expression:
dialects:
- dialect: OSSIE_SQL_2026
expression: AGG(sales.total_amount) / NULLIF(AGG(sales.order_count), 0)

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.

Unlike a field qualifier, the dataset in an AGG(dataset.metric) argument isn't checked against the model, because _field_owners reads only fields. A return that names a dataset this model doesn't have still grades as cosmetic, where SUM(orders.amount) on M0 needs review:

AGG(orders.total_amount) / NULLIF(AGG(orders.order_count), 0)
-> REWRITTEN cosmetic (normalized trees equal)

Could AGG arguments be resolved against each dataset's metrics too, here or in a follow-up?

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.

Done as a follow-up in #815: an AGG argument is now resolved against the datasets that declare the metric, with the same rules as a field qualifier. Your example grades as REWRITTEN review: normalized trees differ.

@christianeu-db
christianeu-db merged commit 32508d1 into apache:main Nov 23, 2026
4 checks passed
MrBlack1995 added a commit to MrBlack1995/ossie that referenced this pull request Nov 24, 2026
… against the model

The grader resolves a dataset qualifier against the authored model before it
compares expression trees, but only for fields: _field_owners reads
datasets[].fields. The argument of AGG(dataset.metric) names a dataset-scoped
metric, which no dataset declares as a field, so its qualifier was dropped
before the comparison. A return of AGG(orders.total_amount) for the authored
AGG(sales.total_amount) graded as a cosmetic rewrite, where SUM(orders.amount)
for SUM(sales.amount) needs review.

AGG arguments are now resolved against the datasets that declare the metric
(_metric_owners), with the same rules as fields: a qualifier that names another
dataset needs review, a respelled or dropped qualifier is cosmetic when one
dataset declares the metric, and it stays meaning when several do.

Follow-up to the review of apache#758. Grader only, no fixture changes.

Co-authored-by: Isaac <no-reply@databricks.com>
jbonofre pushed a commit that referenced this pull request Nov 26, 2026
… against the model (#815)

* fix(compliance): check the dataset in an AGG(dataset.metric) argument against the model

The grader resolves a dataset qualifier against the authored model before it
compares expression trees, but only for fields: _field_owners reads
datasets[].fields. The argument of AGG(dataset.metric) names a dataset-scoped
metric, which no dataset declares as a field, so its qualifier was dropped
before the comparison. A return of AGG(orders.total_amount) for the authored
AGG(sales.total_amount) graded as a cosmetic rewrite, where SUM(orders.amount)
for SUM(sales.amount) needs review.

AGG arguments are now resolved against the datasets that declare the metric
(_metric_owners), with the same rules as fields: a qualifier that names another
dataset needs review, a respelled or dropped qualifier is cosmetic when one
dataset declares the metric, and it stays meaning when several do.

Follow-up to the review of #758. Grader only, no fixture changes.

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

* fix(compliance): fall back to the field owners for an AGG argument that is not a metric

An AGG argument no dataset declares as a metric, or one graded without
metric_owners, lost its qualifier check. It is now checked against the
fields, as on main. The review assertions of the AGG tests name the
"normalized trees differ" detail, so a parse failure cannot pass them.

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

---------

Co-authored-by: Isaac <no-reply@databricks.com>
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