Skip to content

test(compliance): add portability rungs M4-M6 and the FILTER (WHERE) form of M3 - #631

Merged
jbonofre merged 16 commits into
apache:mainfrom
MrBlack1995:test/portability-m3filter-m4-m5-m6
Nov 18, 2026
Merged

jbonofre merged 16 commits into
apache:mainfrom
MrBlack1995:test/portability-m3filter-m4-m5-m6

Conversation

@MrBlack1995

@MrBlack1995 MrBlack1995 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #596: the next portability rungs, one commit each, on top of the M0-M3 set. Each rung still adds one construct, so a difference in a converter's output localizes to it. Happy to drop or split any of these.

Rung Construct Fixture
M3 (new variants) the same filtered aggregate written with the aggregate FILTER (WHERE ...) clause, which expression_language.md makes REQUIRED, qualified and bare. The existing CASE fixtures now omit ELSE 0 (SUM(CASE WHEN ... THEN amount END)), so both forms are the same aggregate, as the spec's note under FILTER (WHERE ...) states; with ELSE 0 they gave 0 where FILTER gives NULL (found by @idk-arsh's execution check on apache/ossie-converters#24) m3/m3_filter_clause_qualified.ossie.yaml, m3/m3_filter_clause_bare.ossie.yaml
M4 two datasets, a declared relationship, and a model-scoped metric across the join m4/m4_cross_dataset.ossie.yaml
M5 metric composition: a model-scoped metric built from two others, carried with their expressions inlined (SUM(sales.amount) / NULLIF(COUNT(sales.order_id), 0)), since a metric expression cannot refer to other metrics (Metric Scoping in core-spec/spec.md) m5/m5_metric_ref.ossie.yaml
M6 date and time scalars: YEAR, DATE_TRUNC, part-first DATEDIFF(part, start, end) m6/m6_date_scalars.ossie.yaml

manifest.yaml gets one entry per rung (and the two M3 variants), and the README table lists M0-M6. Each rung lists its elements_under_test with one kind (metric or field) and the name the grader reports it under (a field as dataset.field); a variant whose metrics are dataset-scoped says so with metrics_in: sales.

Bare variants (M0, M2, M3) are dataset-scoped metrics now. Since #486 a model-scoped metric must qualify dataset.field, so the bare form moves to datasets[].metrics, where the single-part name is the required form. The grader read only the model-root metrics and skipped dataset-scoped ones entirely (and the identity test still passed), so it now collects datasets[].metrics as well, keyed dataset.metric as the spec references them; the identity test asserts every metric in a fixture is graded. M6 writes DATEDIFF(day, ...), the spec's spelling.

M7 and M8 (window and offset functions) are not included: they wait for the default NULL placement in window ORDER BY (#587).

Validation

Related Issues

Refs apache/ossie-converters#24 (portability measurement). Follows #596.

@MrBlack1995

Copy link
Copy Markdown
Contributor Author

@kayemkim would you be able to approve the workflows and take a look when you have a moment? Happy to adjust anything.

@jbonofre
jbonofre self-requested a review October 29, 2026 16:29
jbonofre
jbonofre previously approved these changes Oct 29, 2026

@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 @MrBlack1995!

I checked out the branch and ran the grader test and validate.py on the new and changed M3-M6 fixtures, including SQL validation, and all pass. I also graded the M4-M6 fixtures against themselves, and every finding comes back PORTABLE.

I see two potential follow-ups:

  • test_identity_on_real_m0_m3_fixtures_is_all_portable only loops over m0-m3, so the new M4-M6 fixtures are not covered by the regression test. Please add "m4", "m5", "m6" to the loop and update the "M0-M3" wording in grader/README.md.
  • M5 has reference_form_primary: qualified, but its only variant is reference_form: metric-name.
  • M6's element_under_test is kind: fields and metric with a comma-joined name, so lookups by kind and name won't find it. Splitting it into separate elements, or picking one primary element, would fix that.

MrBlack1995 added a commit to MrBlack1995/ossie that referenced this pull request Oct 30, 2026
…t by kind and name

Follow-ups from the review of apache#631:

- The identity regression test looped over M0-M3 only; it now covers M0-M6,
  and the grader README says so.
- M5's reference_form_primary said "qualified", but its only variant (the
  composite under test) references metric names; it is now "metric-name".
- M6 named "fields and metric" with a comma-joined name, and M2 named
  "metrics" without a name, so a lookup by kind and name found neither.
  Every rung now lists elements_under_test, each with one kind (metric or
  field) and one name.

Two new tests keep the manifest honest: every listed element is found by
kind and name in each variant of its rung, and each primary variant uses
the rung's primary reference form. Both fail on the previous manifest.

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

Copy link
Copy Markdown
Contributor Author

Thanks a lot for checking it out and running everything! All three points are addressed:

  • The identity test now covers M0-M6, and the grader README says so.
  • M5's reference_form_primary and M6's element entry: every rung now lists elements_under_test, each with one kind (metric or field) and one name, so M6 names its two fields and its metric separately (M2 had the same problem with kind: metrics and no name, so it lists its six metrics now). Two new tests keep this honest: every listed element is found by kind and name in each variant, and each primary variant uses the rung's primary reference form. Both fail on the previous manifest.

While checking M5 against current main I found one more thing: since #608, validate.py warns that M5's total_amount / order_count refers to other metrics, which the spec does not allow (Metric Scoping; the metric_name row there is how a query addresses a metric, not what an expression may contain). So M5 now carries the composition the way a converter has to emit it: the parts inlined, SUM(sales.amount) / NULLIF(COUNT(sales.order_id), 0). With that its primary reference form is qualified again, and it validates without warnings. Happy to change it back or drop M5 if you see it differently.

One note for later, not for this PR: since #486 and #608, the bare variants of M0, M2 and M3 get "is not qualified" warnings, because a model-scoped metric must use dataset.field. I'd suggest a small follow-up that moves the bare form into dataset-scoped metrics, where the unqualified name is the required form.

@MrBlack1995

Copy link
Copy Markdown
Contributor Author

@jbonofre thanks again for the review and for running the fixtures yourself, the follow-ups made the manifest a lot more useful. Pushing them dismissed your approval, so whenever you have a moment for another look: the changes are the two commits after 9e425fe, summarized in my comment above. Thanks!

@MrBlack1995

Copy link
Copy Markdown
Contributor Author

One more commit since my last note: 4baea94 drops ELSE 0 from the two M3 CASE fixtures, so they equal the FILTER variants as the spec's note under FILTER (WHERE ...) says (with ELSE 0, rows that exist but do not match gave 0 instead of NULL). Found by an execution check on apache/ossie-converters#24; description updated.

@jbonofre
jbonofre self-requested a review November 1, 2026 17:47
@jbonofre

jbonofre commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thanks @MrBlack1995! I'm doing a new pass 😄

expression:
dialects:
- dialect: ANSI_SQL
expression: AVG(DATEDIFF('day', sales.order_date, sales.ship_date))

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.

The spec writes the date part as a bar keyword: DATEDIFF(day, start_date, end_date) (expression_language.md Date Functions).
DATEDIFF('day', ...) with quotes is the Tableau spelling in the Date Function Mapping table.
A converter that returns the spec form would be graded REWRITTEN ("normalized trees differ"), because sqlglot parses 'day' as a string literal and day as a column.

Suggested change
expression: AVG(DATEDIFF('day', sales.order_date, sales.ship_date))
expression: AVG(DATEDIFF(day, sales.order_date, sales.ship_date))

DATE_TRUNC('month', order_date) is fine as it is, since the spec quotes the part there.

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.

Thanks, fixed in 008c947: AVG(DATEDIFF(day, sales.order_date, sales.ship_date)). DATE_TRUNC('month', ...) stays quoted, as the spec writes it.

Comment thread compliance/portability/manifest.yaml Outdated
description: date and time scalars from the portable core (YEAR, DATE_TRUNC, DATEDIFF part-first)
elements_under_test:
- kind: field
name: order_year

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.

The grader keys fields as dataset.field, but the manifest names them bare: order_year and order_month_start here, and amount_with_tax in M1.
Anyone matching manifest elements to report.findings by (kind, name) won't find a result for any M1 or M6 field.

The new test doesn't catch this because _names in test_grade.py builds its own bare-name set instead of using the grader's keys.

Could we name fields the way the grader does (sales.order_year and so on) and have the test reuse _collect, so the two can't drift apart? For example:

def _names(document, kind):
    return {name for (element_kind, name) in grade._collect(document) if element_kind == kind}

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 in 008c947: fields are named as the grader reports them (sales.amount_with_tax, sales.order_year, sales.order_month_start), and _names is now your version on top of grade._collect. Since the bare variants now hold dataset-scoped metrics (sales.total_amount in the grader), those four variants say metrics_in: sales, and the test expects <dataset>.<metric> for them. The test fails on the previous manifest; 18 grader tests pass.

MrBlack1995 added a commit to MrBlack1995/ossie that referenced this pull request Nov 2, 2026
…pelling in M6

Follow-ups from the second review of apache#631:

- The manifest named fields bare (amount_with_tax, order_year,
  order_month_start), but the grader reports a field as dataset.field, so
  matching manifest elements to findings found no result for M1 or M6.
  Fields are now named sales.<field>, and a variant that carries the
  rung's metrics as dataset-scoped metrics says so with metrics_in: sales
  (the grader reports those as sales.<metric>). The manifest test now uses
  the grader's own _collect keys instead of building a name set of its
  own, so the two cannot drift apart; it fails on the previous manifest.
- M6 wrote DATEDIFF('day', ...), the Tableau spelling in the mapping
  table; the spec writes the part as a keyword, DATEDIFF(day, ...).

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

jbonofre commented Nov 7, 2026

Copy link
Copy Markdown
Member

@MrBlack1995 I'm back on this one 😄

expression:
dialects:
- dialect: ANSI_SQL
expression: SUM(sales.amount) / COUNT(DISTINCT customers.customer_id)

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.

The grader can't tell this expression apart from the two ways a converter is most likely to break it.

_equivalent_tree drops every column table qualifier before comparing. Until now every rung had a single dataset, so that only erased spelling. Here customer_id is declared by both sales and customers, so the qualifier carries meaning. Against main grader, all three of these come back REEWRITTEN "cosmetic (normalized trees equal)":

  • SUM(sales.amount) / COUNT(DISTINCT customers.customer_id): as authored.
  • SUM(sales.amount) / COUNT(DISTINCT sales.customer_id): join collapsed, now also counts customer ids with no customer row.
  • SUM(amount) / COUNT(DISTINCT customer_id): unqualified, ambiguous at model scope (validate.py only warns).

interop/portability.py in ossie-converters counts a "cosmetic" REWRITTEN as portable. So a converter that loses the cross-dataset reference scores as portable on the rung that exists to measure it. _repair_by_expression has the same blind spot: a metric that is renamed and also re-pointed to sales.customer_id is paired as "expression equivalent".

To fix that, I suggest to keep the qualifier for any field name that more than one dataset in the input declares, and strip it as before otherwise. M0-M3 each have one dataset, so their grades don't change.

def _ambiguous_fields(document):
    """Field names declared by more than one dataset. For these the dataset
    qualifier says which column is meant, so normalization must keep it."""
    owners = {}
    if isinstance(document, dict):
        for dataset in document.get("datasets") or []:
            if not isinstance(dataset, dict):
                continue
            for field_def in dataset.get("fields") or []:
                if isinstance(field_def, dict) and field_def.get("name"):
                    owners.setdefault(str(field_def["name"]).lower(), set()).add(dataset.get("name"))
    return frozenset(name for name, datasets in owners.items() if len(datasets) > 1)

In _equivalent_tree(left, right, keep_qualified=frozenset()):

        for column in tree.find_all(exp.Column):
            if column.name.lower() in keep_qualified:
                # Declared by more than one dataset: the qualifier is meaning.
                continue
            # Drop the table qualifier so sales.amount and amount compare equal.
            column.set("table", None)

then compute keep_qualified = _ambiguous_fields(input_document) once in grade() and pass it through _classify_present and _repair_by_expression to both _equivalent_tree calls. I ran this against main grader: the existing tests still pass, and the M4 cases come back as review.

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.

Thanks, good catch: M4 is the first rung where the qualifier carries meaning, and the grader erased it. Applied your approach in 3505677: _ambiguous_fields() reads the field names more than one input dataset declares, grade() computes it once and passes it through _classify_present and _repair_by_expression to both _equivalent_tree calls. M0-M3 grade as before (one dataset each). I also checked the converters side: interop/portability.py in ossie-converters#141 and the #65 runner both go through this grader and do no comparison of their own, so they pick the fix up with the next submodule bump.

MrBlack1995 added a commit to MrBlack1995/ossie that referenced this pull request Nov 8, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
idk-arsh added a commit to idk-arsh/ossie-converters that referenced this pull request Nov 10, 2026
…ty grader

The core grader compares normalized sqlglot trees, so a rewritten metric
whose trees differ can only be marked for review. portability_execution.py
runs the authored and the returned expression of each metric the grader
marks REWRITTEN in DuckDB on the same small edge-case data and reports
SAME_ON_TEST_DATA (evidence, not proof), DIFFERENT (with the smallest row
set found and both results on it) or NOT_RUN (with the reason).

The grader is loaded from the pinned ossie submodule. check() takes the
grader's report for the round trip when the caller already has one, so a
portability step and this check read the same findings; a single pair can
also be checked with python -m interop.portability_execution. It is
report-only: exit 0 whatever the findings, 2 when a document or the grader
cannot be loaded.

DuckDB runs in memory with external access and extension loading off and
its configuration locked. Division by zero is NULL
(ieee_floating_point_ops = false, plus error_on_division_by_zero = false on
DuckDB 2, which otherwise raises), so a rewrite that only adds a NULLIF
guard agrees, as discussed on apache#24. Tests set the M3 ELSE 0 form
themselves rather than reading it from the fixture, which apache/ossie#631
changes.

Refs apache#24.
@MrBlack1995
MrBlack1995 force-pushed the test/portability-m3filter-m4-m5-m6 branch from 3505677 to ae3efae Compare November 12, 2026 16:35
MrBlack1995 added a commit to MrBlack1995/ossie that referenced this pull request Nov 12, 2026
…t by kind and name

Follow-ups from the review of apache#631:

- The identity regression test looped over M0-M3 only; it now covers M0-M6,
  and the grader README says so.
- M5's reference_form_primary said "qualified", but its only variant (the
  composite under test) references metric names; it is now "metric-name".
- M6 named "fields and metric" with a comma-joined name, and M2 named
  "metrics" without a name, so a lookup by kind and name found neither.
  Every rung now lists elements_under_test, each with one kind (metric or
  field) and one name.

Two new tests keep the manifest honest: every listed element is found by
kind and name in each variant of its rung, and each primary variant uses
the rung's primary reference form. Both fail on the previous manifest.

Co-authored-by: Isaac <no-reply@databricks.com>
MrBlack1995 added a commit to MrBlack1995/ossie that referenced this pull request Nov 12, 2026
…pelling in M6

Follow-ups from the second review of apache#631:

- The manifest named fields bare (amount_with_tax, order_year,
  order_month_start), but the grader reports a field as dataset.field, so
  matching manifest elements to findings found no result for M1 or M6.
  Fields are now named sales.<field>, and a variant that carries the
  rung's metrics as dataset-scoped metrics says so with metrics_in: sales
  (the grader reports those as sales.<metric>). The manifest test now uses
  the grader's own _collect keys instead of building a name set of its
  own, so the two cannot drift apart; it fails on the previous manifest.
- M6 wrote DATEDIFF('day', ...), the Tableau spelling in the mapping
  table; the spec writes the part as a keyword, DATEDIFF(day, ...).

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

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #642 merged: the conflicts in grade.py are resolved (the qualifier fix now goes through #642's _rewritten helper), and the fixtures this PR adds now declare spec version 0.3.0.dev0, as the schema requires since #691. The compliance tests pass (34, plus #642's one xfail) and all 13 fixtures validate. Ready for another look whenever you have time.

MrBlack1995 and others added 4 commits November 16, 2026 06:50
…ters#24

Issue #576 was transferred to apache/ossie-converters#24 with the
converters; the ladder, grader and manifest still cited the old number,
which now resolves to nothing.

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

M4 is the first rung with two datasets, and customer_id is declared by both
sales and customers. The grader stripped every table qualifier before
comparing trees, so a converter that re-pointed COUNT(DISTINCT
customers.customer_id) to sales.customer_id, or dropped the qualifiers, was
graded as a cosmetic rewrite, and _repair_by_expression paired such a
renamed metric as expression-equivalent.

_ambiguous_fields() reads the field names that more than one input dataset
declares; for those the qualifier is kept, for all others it is stripped as
before (M0-M3 have one dataset each, so their grades do not change). Three
regression tests; two fail on the previous grader.

Suggested-by: Jean-Baptiste Onofré <jbonofre@apache.org>
Co-authored-by: Isaac <no-reply@databricks.com>
main moved the in-development version to 0.3.0.dev0 (apache#691), and the
schema pins it, so the fixtures this PR adds declare it too.

Co-authored-by: Isaac <no-reply@databricks.com>
… declares the field

Review of apache#631. The shared-field rule kept or dropped a qualifier by the
field name alone, so a field requalified with its own dataset needed
review when another dataset declared the name too, and a metric that
named a dataset not declaring the field was cosmetic. Each column is now
resolved to the dataset it names before the trees are compared: a bare
name in a field expression or dataset-scoped metric is the element's own
dataset, elsewhere the one dataset that declares it, and a written
qualifier is kept as written.

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

Copy link
Copy Markdown
Contributor Author

Rebased onto main (now d2c4643): #729, #730 and #732 changed the same grader functions over the weekend, so this PR had conflicts. The resolution keeps both sides: their sql survival rule and identifier-boundary diagnostics, and this PR's qualifier resolution; nothing in this PR's own logic changed. The compliance tests pass (43) and all 13 fixtures validate. The push dismissed the approval, sorry @kayemkim: could you re-approve when you have a moment?

idk-arsh added a commit to idk-arsh/ossie-converters that referenced this pull request Nov 16, 2026
…ty grader

The core grader compares normalized sqlglot trees, so a rewritten metric
whose trees differ can only be marked for review. portability_execution.py
runs the authored and the returned expression of each metric the grader
marks REWRITTEN in DuckDB on the same small edge-case data and reports
SAME_ON_TEST_DATA (evidence, not proof), DIFFERENT (with the smallest row
set found and both results on it) or NOT_RUN (with the reason).

The grader is loaded from the pinned ossie submodule. check() takes the
grader's report for the round trip when the caller already has one, so a
portability step and this check read the same findings; a single pair can
also be checked with python -m interop.portability_execution. It is
report-only: exit 0 whatever the findings, 2 when a document or the grader
cannot be loaded.

DuckDB runs in memory with external access and extension loading off and
its configuration locked. Division by zero is NULL
(ieee_floating_point_ops = false, plus error_on_division_by_zero = false on
DuckDB 2, which otherwise raises), so a rewrite that only adds a NULLIF
guard agrees, as discussed on apache#24. Tests set the M3 ELSE 0 form
themselves rather than reading it from the fixture, which apache/ossie#631
changes.

Refs apache#24.
kayemkim
kayemkim previously approved these changes Nov 17, 2026

@kayemkim kayemkim 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.

The rebase leaves the grading as it was at 282fe83: every variant I ran then comes back the same on d2c4643 merged with current main. The sql rule from #729 and #730 also holds on the M4 qualifier cases. A requalified sql is cosmetic, one that names the other dataset needs review, and an ANSI_SQL entry that survives does not cover for a sql that changed.

Comment on lines +149 to +155
if home:
return column.table.lower() if column.table else home
declared_by = owners.get(column.name.lower(), frozenset())
if not declared_by:
return None # no dataset declares it, so there is nothing to check against
if column.table:
return column.table.lower()

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.

A returned qualifier is now kept as written, so when a converter renames a dataset, every metric and field that names it is graded as dropped.

Lightdash names a dataset after its source table. For M0.ansi.qualified it returns a dataset orders (source: samples.sales.orders) and orders_total_amount = SUM(orders.amount) for the authored dataset sales and total_amount = SUM(sales.amount). Main pairs the two as "identity not preserved" (the review column). With this change orders stays orders, the trees differ, and total_amount is graded DROPPED_SILENT, plus an unrelated ADDED orders_total_amount.
The M1 field gets the same treatment (amount * 1.1 comes back as orders.amount * 1.1).

I graded all 120 portability cases from the latest Interop matrix run on apache/ossie-converters main with main's grader and with this one. 19 lightdash elements in 8 cases (M0 x3, M1, M2 x2, M3 x2) move from review to DROPPED_SILENT, and nothing else changes. The converters table would then show lightdash silently dropping metrics it actually returned.

I suggest when a returned dataset has the same source as an authored one, treat it as that dataset, and map its qualifiers on the returned side before resolving. I tried this locally. The 120 CI cases then grade exactly as on main, and all 43 tests here still pass, including test_a_field_qualified_by_another_dataset_needs_review.

Could we add a test built from lightdash's real M0 return, so this can't regress?

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.

Fixed in 0995481 as you suggested: a returned dataset that reads the source of exactly one authored dataset is treated as that dataset, and its qualifiers are mapped on the returned side before resolving. The 120 CI cases now grade as on main, and test_a_dataset_renamed_after_its_source_is_the_authored_dataset is built from lightdash's real M0 return. Details in the comment below.

Comment on lines +18 to +23
# M5 ladder rung: metric composition. A metric expression cannot refer to other
# metrics (core-spec/spec.md, Metric Scoping; expression_language.md), so a
# composed measure in a source tool (avg_order_value = total_amount / order_count)
# is carried with its parts inlined: a ratio of two aggregates over qualified
# dataset.field references, NULL when there are no orders. The two base metrics
# stay alongside it. Single fixture.

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.

Since #703 this premise no longer holds. A model-scoped metric may now evaluate a dataset-scoped metric with AGG(dataset.metric) (core-spec/spec.md, Metric Scoping rule 6, expression_language.md, the AGG section). This commit predates #703, so it was right when you wrote it.

The fixture is still valid, and inlining is still a legitimate way to carry composition. But the rung should not say it is the only way. Could we reword this comment, the construct in manifest.yaml and the M5 row in the README to say the composition is carried inlined, without claiming that metrics cannot reference metrics?

A follow-up variant that composes AGG(sales.total_amount) / AGG(sales.order_count) over dataset-scoped base metrics would test real composition. That doesn't need to block this PR.

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.

Reworded in 639958b: the fixture comment, the manifest construct and the README row now say the composition is carried inlined, and that AGG(dataset.metric) is not tested by this rung. Glad to add the AGG variant as a follow-up.

MrBlack1995 and others added 2 commits November 17, 2026 20:51
…source as that dataset

A converter that names a dataset after its source table (lightdash returns
orders for an authored sales over samples.sales.orders) renamed it. Since
qualifiers are kept as written, its metrics and fields were graded as dropped
plus an unrelated addition. Map the renamed dataset's qualifiers on the
returned side to the authored dataset before resolving, when exactly one
authored dataset has that source. The 120 cases of the latest Interop matrix
run now grade as on main. Adds a test built from lightdash's real M0 return.

Co-authored-by: Isaac <no-reply@databricks.com>
…trics cannot reference metrics

Since apache#703 a model-scoped metric may evaluate a dataset-scoped metric with
AGG(dataset.metric). Reword the M5 fixture comment, the manifest construct and
the README row.

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

MrBlack1995 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @jbonofre, both are fixed.

Renamed datasets (0995481), along the lines you suggested: _dataset_aliases maps a returned dataset that is not authored under its own name, but reads the source of exactly one authored dataset, to that dataset, and its qualifiers on the returned side are mapped before resolving. When two authored datasets share the source, nothing is mapped rather than guessing.

I graded the 120 portability cases of the latest Interop matrix run on ossie-converters main (run 44032883483) with main's grader, with d2c4643 and with this commit. At d2c4643 I get what you found: 19 lightdash elements in 8 cases move to DROPPED_SILENT, each with an unrelated ADDED. With the fix, all 120 cases grade exactly as on main.

New tests: test_a_dataset_renamed_after_its_source_is_the_authored_dataset, built from lightdash's real M0.ansi.qualified return; the M1 field case (orders.amount * 1.1); and two cases where no alias applies (two authored datasets with the same source, and a returned name that is an authored dataset). All four fail on d2c4643. 47 tests pass here, 50 on top of current main, and test_a_field_qualified_by_another_dataset_needs_review still passes.

M5 (639958b): the fixture comment, the manifest construct and the README row now say the composition is carried inlined, and that composition through AGG(dataset.metric) is not tested by this rung. I'm happy to add the AGG(sales.total_amount) / AGG(sales.order_count) variant as a follow-up once this lands.

@kayemkim kayemkim 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.

The alias only moves a qualifier onto the dataset that reads the same source, so the M4 check still holds through a rename. With both datasets renamed, SUM(cust.amount) for an authored SUM(sales.amount) still needs review, and so does a return that swaps the two names. My earlier variants grade the same as before.

@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 @MrBlack1995!

I graded the 120 portability cases from the latest Interop matrix run on apache/ossie-converters main, with main's grader and with this one, and every finding is the same. I also ran the 14 graded converters locally on the new fixtures (the M3 FILTER variants, M4-M6, and the bare variants as dataset-scoped metrics), with the converters' pinned submodule and the PR's compliance/portability. The grades look right, except for one M6 issue that the grader already has on main.

@MrBlack1995

Copy link
Copy Markdown
Contributor Author

Thanks for running all 14 converters on the new rungs. Which M6 issue do you mean? If it's a grader gap, I'm happy to take it as a follow-up once this lands.

idk-arsh added a commit to idk-arsh/ossie-converters that referenced this pull request Nov 19, 2026
Since apache/ossie#631 the grader keys a metric declared under
datasets[].metrics as dataset.metric. _find_metric now looks such a name
up under that dataset's metrics, and a bare name in a dataset-scoped
metric resolves to its home dataset, as the spec reads it, even when
another dataset declares a field of the same name.

Point 2 of the apache#127 review.
christianeu-db pushed a commit to apache/ossie-converters that referenced this pull request Nov 19, 2026
…ty grader (#127)

* test(interop): add a report-only execution check behind the portability grader

The core grader compares normalized sqlglot trees, so a rewritten metric
whose trees differ can only be marked for review. portability_execution.py
runs the authored and the returned expression of each metric the grader
marks REWRITTEN in DuckDB on the same small edge-case data and reports
SAME_ON_TEST_DATA (evidence, not proof), DIFFERENT (with the smallest row
set found and both results on it) or NOT_RUN (with the reason).

The grader is loaded from the pinned ossie submodule. check() takes the
grader's report for the round trip when the caller already has one, so a
portability step and this check read the same findings; a single pair can
also be checked with python -m interop.portability_execution. It is
report-only: exit 0 whatever the findings, 2 when a document or the grader
cannot be loaded.

DuckDB runs in memory with external access and extension loading off and
its configuration locked. Division by zero is NULL
(ieee_floating_point_ops = false, plus error_on_division_by_zero = false on
DuckDB 2, which otherwise raises), so a rewrite that only adds a NULLIF
guard agrees, as discussed on #24. Tests set the M3 ELSE 0 form
themselves rather than reading it from the fixture, which apache/ossie#631
changes.

Refs #24.

* feat(interop): run the execution check in Runner.portability_case

As described in #141, Runner.portability_case now calls
portability_execution.check(input_document, returned_document,
converter=..., graded=report) right after grader.grade(...) and stores
the result as `execution` next to `grading`, so both read the same
findings. It is saved in the case's result.json and in results.json. A
skipped case is not executed (`execution` stays None), and a rejected
return has nothing to execute. Without DuckDB each check is NOT_RUN with
the reason. Report-only: the exit status is unchanged, with or without
--strict.

portability_execution.grader() now loads the grader through
interop.portability.load_grader, so the runner and the check share one
grader module. as_dict() gives the JSON-ready report the runner stores.

Refs #24, #141.

* fix(interop): follow-ups from the #127 review

- Take "cosmetic" from the grader's own finding instead of comparing the
  trees again, so the check cannot skip a pair the grader, with more
  context, marks for review.
- Read the portable `sql` form as OSSIE_SQL_2026, shadowing an
  OSSIE_SQL_2026 dialect entry, the way the grader reads it (apache/ossie#642).
- Move DuckDB into an optional `execution` dependency group; CI installs it.
  Without it every execution finding stays NOT_RUN.

* fix(interop): find dataset-scoped metrics in the execution check

Since apache/ossie#631 the grader keys a metric declared under
datasets[].metrics as dataset.metric. _find_metric now looks such a name
up under that dataset's metrics, and a bare name in a dataset-scoped
metric resolves to its home dataset, as the spec reads it, even when
another dataset declares a field of the same name.

Point 2 of the #127 review.
christianeu-db added a commit to christianeu-db/ossie-converters that referenced this pull request Nov 21, 2026
apache/ossie#631 adds the M6 rung (YEAR, DATE_TRUNC, DATEDIFF). It shows
two converter gaps: the round trip upper-cases the DATE_TRUNC unit, which
the grader scores as REWRITTEN, and `translate` has no verified DATABRICKS
form for DATEDIFF. Both rung tests are strict xfails until the converter
handles them.

The M0 qualified OSSIE_SQL case now passes against the sql-primary
grader, as its comment anticipated, so its xfail goes.

Co-authored-by: Isaac <no-reply@databricks.com>
christianeu-db added a commit to apache/ossie-converters that referenced this pull request Nov 23, 2026
…ble_extensions (#247)

* chore(deps): bump ossie from `ee89dbd` to `344259a`

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

* test(databricks): expect the M6 ladder rung to fail, drop the M0 xfail

apache/ossie#631 adds the M6 rung (YEAR, DATE_TRUNC, DATEDIFF). It shows
two converter gaps: the round trip upper-cases the DATE_TRUNC unit, which
the grader scores as REWRITTEN, and `translate` has no verified DATABRICKS
form for DATEDIFF. Both rung tests are strict xfails until the converter
handles them.

The M0 qualified OSSIE_SQL case now passes against the sql-primary
grader, as its comment anticipated, so its xfail goes.

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

* test(interop): stop pairing the bare and qualified ladder fixtures by name

The submodule's bare M0-M3 fixtures now carry their metrics at dataset
scope, so they no longer name the same metrics as the model-scoped
qualified fixtures. The tests derive the bare form from the qualified
fixture instead, as the module already does for any metric whose shape
it depends on.

The grader rejects only a missing or empty return since
apache/ossie#757, so the rejection test passes `{}`, which is what the
matrix passes when an export fails.

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

* fix(converters): write nonportable_extensions with object data

apache/ossie#522 renames `custom_extensions` to `nonportable_extensions`
with no alias, and types `data` as an object instead of a JSON string.
The SDK renames `OssieCustomExtension` to `OssieNonportableExtension`
and types `data` as `dict`.

Every converter now writes and reads the new field with object data.
Where a payload may hold values JSON cannot (dates from a YAML loader),
it still goes through the converter's existing JSON encoding, now
decoded back to an object. Committed fixtures and goldens move to the
new shape.

Vendor-side formats keep their own shapes: OBML `customExtensions` data
stays a string, and Honeydew's `ossie` metadata keeps its item names.
thoughtspot keeps reading both names and both shapes, and keeps a
document that still uses the old name on it. orionbelt's v0.1 shim
migrates a legacy `custom_extensions` list before it reads it.

Tests that built a malformed JSON string cannot be constructed against
the SDK any more and are removed, along with lightdash's
EXTENSION_DATA_INVALID issue, which can no longer occur.

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

* fix(databricks): translate DATEDIFF by day and keep the M6 rung portable

The M6 ladder rung (YEAR, DATE_TRUNC, DATEDIFF) did not survive a round
trip, for three reasons:

- The default parser reads Ossie's part-first DATEDIFF(day, start, end)
  end-first, with the part as a column. The Ossie parser now reads the
  part first. Only the day count is translated: the Ossie specification
  does not say whether DATEDIFF counts part boundaries or whole parts
  elapsed (Databricks), and the two agree only for the days between two
  dates.
- sqlglot upper-cases the DATE_TRUNC unit, so DATE_TRUNC('month', d)
  came back as 'MONTH'. Ossie output now writes the unit in lower case,
  as the specification does.
- The Databricks parser wraps the argument of YEAR, MONTH, DAY and
  DAYOFYEAR in a TO_DATE that was not written. The wrapper is dropped on
  parse, so YEAR(x) comes back as YEAR(x).

The M6 xfails go, as does the M0 xfail that expected the sql-primary
grader.

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

* test(dbt): move the ratio helper tests to nonportable_extensions

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

* fix(atlan, wisdom): write nonportable_extensions with object data

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.

3 participants