Repository navigation
feat(compliance): add Layer 3 wide table query cases - #716
Conversation
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
left a comment
There was a problem hiding this comment.
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 readorders.amoutas 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.yamlto thecompliance-validatetarget, somake compliancecovers 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:
compliance/wide_table/next tocompliance/query/works for me. It keeps one folder per query interface.- 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.
- a
query.ossie.sqlper row case would let the expected rows be derived in the repo, asreference.duckdb.sqldoes forcompliance/query/. I would do that in a follow-up. Keepingexpected.jsonis 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.
|
Thanks for checking every case.
The three open questions stay as you answered them, with no change in this PR. |
christianeu-db
left a comment
There was a problem hiding this comment.
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:
- Align the expected-results format with .ost and move setup details into a README or test setup.
- Add the ossie.sql files.
- Build a basic Layer 3 → Layer 2 reference implementation / expander.
- Consolidate these tests into .ost once the runner is ready.
Thanks again for pushing this forward!
| "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.", |
There was a problem hiding this comment.
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.
Compliance cases for the Wide Table Query Interface (
core-spec/wide_table_semantics.md), incompliance/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.mdapply. Rows have no order. Inexpected.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:
E_AMBIGUOUS_PATH. The specification gives no data for B.3, and the cases need a second model withstore_sales. They can follow in another PR.AGG(dataset.metric)(docs(core-spec): Let model-scoped metrics evaluate dataset-scoped metrics with AGG() #703).Open questions:
compliance/wide_table/next tocompliance/query/, or a folder insidecompliance/query/?behavior. Should a case carry them as data that a harness can check?compliance/query/derives each expected result with a reference DuckDB query. Should each row case here also carry its Layer 2 lowering, aquery.ossie.sqlover 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 inexpected.sql, as incompliance/query/, instead of JSON?Checks:
validation/validate.py.dev/.rat-excludes). The other new files carry the ASF header.cc @christianeu-db