Skip to content

feat(compliance): add Layer 3 wide table query cases - #716

Merged
christianeu-db merged 2 commits into
apache:mainfrom
ekut:layer3-compliance
Nov 13, 2026
Merged

christianeu-db merged 2 commits into
apache:mainfrom
ekut:layer3-compliance

Conversation

@ekut

@ekut ekut commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Compliance cases for the Wide Table Query Interface (core-spec/wide_table_semantics.md), in compliance/wide_table/. They give an engine or a binding of Layer 3 a way to check the rows and errors that Section 9 requires. Each case is a query in the JSON shape of Section 3.7 and its expected rows or Section 8 error code. 15 cases return rows and 21 raise an error. Most of the error cases have no counterpart in Appendix B, which shows five of the 17 codes and not the order in which they apply.

The data and the model are those of Appendix B: customers, orders, returns, visits, and tickets. The cases follow the examples of Section 1.3, Section 5.2, Section 6.1, and Appendix B.1, B.2, B.4, and B.5. Where an example gives no value, the case computes it from the data of B.1 and B.2 by the rules of Sections 3 and 5. The error cases cover rows 1 to 16 of Section 8, and two cases check the order of the table.

The result and comparison rules of compliance/query/README.md apply. Rows have no order. In expected.json, a JSON number without a fraction or an exponent is an exact numeric, and any other number is approximate. revenue_per_customer (Section 5.2, 650 / 4) casts its numerator to DOUBLE, because the division of two exact numerics has an implementation-defined scale.

Not included:

Open questions:

  1. Placement: compliance/wide_table/ next to compliance/query/, or a folder inside compliance/query/?
  2. For codes 13, 14, and 16, Section 8 also requires the error to identify the dimension or the filter, and the metric. How an engine reports them depends on its binding, so the cases check only the code and name the objects in behavior. Should a case carry them as data that a harness can check?
  3. compliance/query/ derives each expected result with a reference DuckDB query. Should each row case here also carry its Layer 2 lowering, a query.ossie.sql over the same model, so that a Layer 2 engine or the harness in feat(ost): add .ost, a file format for idempotent test scripts #667 can derive the expected rows? And should the expected rows go in expected.sql, as in compliance/query/, instead of JSON?

Checks:

  • The model passes validation/validate.py.
  • The rows of the 15 result cases match the rows that dactopus-ossie-clickhouse, a ClickHouse engine I maintain, returns on ClickHouse 26.9.
  • JSON files are excluded from the license header check (dev/.rat-excludes). The other new files carry the ASF header.

cc @christianeu-db

Compliance cases for core-spec/wide_table_semantics.md: the data and
model of Appendix B, and one folder per case with the query in the JSON
shape of Section 3.7 and its expected rows or Section 8 error code.
Every expected value comes from the specification's examples (Sections
1.3, 5.2 and 6.1, Appendix B.1, B.2, B.4 and B.5) or from Section 8.
@jbonofre
jbonofre self-requested a review November 13, 2026 05:01
jbonofre
jbonofre previously approved these changes Nov 13, 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.

Thanks for this. It's a solid start for Layer 3 compliance. I checked the expected rows of the 15 result cases against the Appendix B data, and the 21 error cases against the order of the Section B table. They all hold, super good!

I have a few suggestions:

  • e12: SUM(orders.amount) OVER () matches the Section 5.2 example, but someone could read orders.amout as a field outside every aggregate (row 10). SUM(SUM(orders.amount)) OVER () would leave row 11 as the only match.
  • Makefile: please add compliance/wide_table/retail/retail_model.ossie.yaml to the compliance-validate target, so make compliance covers the new model.
  • Coverage: every order, return and visit matches a customer, so no case check unmatched home rows or NULL groups (S1, Sections 4 and 5.5). An engine using INNER JOIN would pass. Keeping this data identical to Appendix B makes sense, so a second data set with unmatched and NULL keys in a later PR would be a good addition.

On the open questions:

  1. compliance/wide_table/ next to compliance/query/ works for me. It keeps one folder per query interface.
  2. checking only the code is fine for now. Optional structured fields that a harness can check, such as the dimension or filter and the metric, could come in a follow-up.
  3. a query.ossie.sql per row case would let the expected rows be derived in the repo, as reference.duckdb.sql does for compliance/query/. I would do that in a follow-up. Keeping expected.json is fine since the binding is JSON.

running_revenue becomes SUM(SUM(orders.amount)) OVER (), so no field
stands outside every aggregate and E_DEFERRED_WINDOWED_METRIC is the
only code of Section 8 that applies. The compliance-validate target
now validates compliance/wide_table/retail/retail_model.ossie.yaml.
@ekut

ekut commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking every case.

  • e12: running_revenue is now SUM(SUM(orders.amount)) OVER (), so row 11 is the only row of Section 8 that matches.
  • Makefile: compliance-validate now validates compliance/wide_table/retail/retail_model.ossie.yaml.
  • Coverage: agreed. A second data set with unmatched home rows and NULL keys can come in the next PR, with Appendix B.3 and E_AMBIGUOUS_PATH.

The three open questions stay as you answered them, with no change in this PR.

@github-actions github-actions Bot added the infra label Nov 13, 2026
@ekut
ekut requested a review from jbonofre November 13, 2026 06:14
@christianeu-db christianeu-db added this to the 0.3.0-incubating milestone Nov 13, 2026

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

Thanks @ekut, this looks great! I left one small comment inline around the test setup details, but that can be addressed in a follow-up.

To your questions:

  • RE code placement: The current location makes sense for now. We can look at merging these with the other tests once the .ost runner has landed.
  • RE reporting: The current approach of checking the code works for me for now.
  • RE lowering: It would be great to include the ossie.sql files in each folder as well. This can be a follow-up PR and would give us a starting point for a Layer 3 → Layer 2 reference implementation / expander, similar to the Layer 2 work underway in #502.
  • RE expected format: If it's not too much trouble, I'd prefer either the tabular format introduced in #667. That would make migrating these cases to .ost much simpler.

Again, this PR is a big step forward for Ossie compliance! With 0.3.0 coming in the next few weeks, let's see how much we can land before the release.

Some potential next steps, roughly in order:

  1. Align the expected-results format with .ost and move setup details into a README or test setup.
  2. Add the ossie.sql files.
  3. Build a basic Layer 3 → Layer 2 reference implementation / expander.
  4. Consolidate these tests into .ost once the runner is ready.

Thanks again for pushing this forward!

Comment on lines +2 to +4
"title": "Two metrics share a dimension",
"question": "What are the order and return amounts by customer region?",
"behavior": "Each metric is a branch from its own dataset to customers. The keys are the regions of either branch; a region missing from a branch takes the empty-input value of SUM, NULL.",

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.

These details probably belong alongside the query or test setup. As a first step, we could capture them in READMEs in the test folders, then eventually migrate them into comments in the .ost test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants