Repository navigation
test(compliance): add an M5 variant that composes through AGG(dataset.metric) - #758
Conversation
….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>
3f5a7d3 to
7d5b0fa
Compare
christianeu-db
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
… 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>
… 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>
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), soM5.agg_refcomposes the sameavg_order_valuethat way:OSSIE_SQL_2026, sinceAGGis defined there only. It keeps the primary'sNULLIF, so both forms are NULL when there are no orders.composition-form. The M5 comment, the manifest construct and the README row now describe both.Validation
m5_agg_ref.ossie.yamlpassesvalidation/validate.py; replacingAGG(sales.total_amount)withAGG(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.AGGinto the base metric's expression grades as review, since the grader cannot prove the two equal.Related Issues
Follows #631 (suggested in its review) and #703. Refs apache/ossie-converters#24. Independent of #700, #756 and #757.