From 538b19afd31717f07d79dfe08338505db8ebe0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JB=20Onofr=C3=A9?= Date: Sun, 15 Nov 2026 18:57:50 +0100 Subject: [PATCH] fix(compliance): follow up on the wide table stores fixture Address the review of #728: - Add a21: store_returns.total_returns by date_dim.year on stores_ambiguous succeeds, because E_AMBIGUOUS_PATH applies only to paths between datasets that the lowering joins. - Renumber the stores error cases so they follow the order of the Section 8 table: e22 E_NO_PATH, e23 E_NO_ANCHOR, e24 and e25 E_AMBIGUOUS_PATH. - Rename the physical date_dim column to d_year, since YEAR is a reserved word in standard SQL. The model field stays year. - Correct the a17 and README explanation: an INNER JOIN drops only SS4 and leaves a NULL group of 40. - State that the stores rows are not from the specification, and scope the retail fixture headers to the retail cases. - Validate every wide table model with a glob in compliance-validate. --- Makefile | 2 +- compliance/wide_table/README.md | 29 +++++++++++-------- .../expected.json | 4 +-- .../a18_anchor_with_metric/expected.json | 2 +- .../cases/a19_sales_by_year/expected.json | 2 +- .../a20_filter_on_sale_year/expected.json | 2 +- .../expected.json | 12 ++++++++ .../query.json | 4 +++ .../expected.json | 0 .../query.json | 0 .../expected.json | 0 .../query.json | 0 .../expected.json | 0 .../query.json | 0 .../expected.json | 0 .../query.json | 0 compliance/wide_table/retail/retail.sql | 7 +++-- .../wide_table/retail/retail_model.ossie.yaml | 6 ++-- compliance/wide_table/stores/stores.sql | 7 +++-- .../stores/stores_ambiguous_model.ossie.yaml | 2 +- .../wide_table/stores/stores_model.ossie.yaml | 2 +- 21 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 compliance/wide_table/cases/a21_single_path_on_ambiguous_model/expected.json create mode 100644 compliance/wide_table/cases/a21_single_path_on_ambiguous_model/query.json rename compliance/wide_table/cases/{e24_no_path_stores => e22_no_path_stores}/expected.json (100%) rename compliance/wide_table/cases/{e24_no_path_stores => e22_no_path_stores}/query.json (100%) rename compliance/wide_table/cases/{e25_no_anchor_stores => e23_no_anchor_stores}/expected.json (100%) rename compliance/wide_table/cases/{e25_no_anchor_stores => e23_no_anchor_stores}/query.json (100%) rename compliance/wide_table/cases/{e22_ambiguous_path_dimension => e24_ambiguous_path_dimension}/expected.json (100%) rename compliance/wide_table/cases/{e22_ambiguous_path_dimension => e24_ambiguous_path_dimension}/query.json (100%) rename compliance/wide_table/cases/{e23_ambiguous_path_filter => e25_ambiguous_path_filter}/expected.json (100%) rename compliance/wide_table/cases/{e23_ambiguous_path_filter => e25_ambiguous_path_filter}/query.json (100%) diff --git a/Makefile b/Makefile index 54a43b93..c6b3e284 100644 --- a/Makefile +++ b/Makefile @@ -178,7 +178,7 @@ compliance-validate: DEPENDENCIES := $(UV) compliance-validate: ## Validate compliance models and portability fixtures $(call check_deps,$(DEPENDENCIES)) @echo "--- Validating compliance fixtures ---" - @$(UV) run --no-project validation/validate.py compliance/portability/m*/*.ossie.yaml compliance/query/scott/scott_model.ossie.yaml compliance/wide_table/retail/retail_model.ossie.yaml compliance/wide_table/stores/stores_model.ossie.yaml compliance/wide_table/stores/stores_ambiguous_model.ossie.yaml + @$(UV) run --no-project validation/validate.py compliance/portability/m*/*.ossie.yaml compliance/query/scott/scott_model.ossie.yaml compliance/wide_table/*/*.ossie.yaml @echo "--- Compliance fixture validation complete ---" .PHONY: compliance-query diff --git a/compliance/wide_table/README.md b/compliance/wide_table/README.md index fc105136..6905c8ad 100644 --- a/compliance/wide_table/README.md +++ b/compliance/wide_table/README.md @@ -22,9 +22,11 @@ Wide table compliance tests Compliance tests for the [Wide Table Query Interface](../../core-spec/wide_table_semantics.md) -(Layer 3). Cases use one of the fixtures below. The data and the expected -results come from the examples of the specification: Section 1.3, Section 5.2, -Section 6.1, and Appendix B. +(Layer 3). Cases use one of the fixtures below. The `retail` data and its +expected results come from the examples of the specification: Section 1.3, +Section 5.2, Section 6.1, and Appendix B. Appendix B.3 gives no rows, so the +`stores` data is chosen for its cases, and their expected results follow from +it. The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY are to be interpreted as described in BCP 14 @@ -45,9 +47,10 @@ Layout | `cases//query.json` | Query under test, in the JSON binding of Section 3.7 | | `cases//expected.json` | Expected result or error, and which fixture to load | -Cases `a*` return rows. Cases `e*` raise an error; they follow the order of -the table in Section 8 where applicable, and `e20` and `e21` test that order. -`e22` and `e23` cover `E_AMBIGUOUS_PATH` (Section 8, row 17). +Cases `a*` return rows. Cases `e*` raise an error. `e01` to `e19` follow the +order of the table in Section 8, and `e20` and `e21` test that order. `e22` to +`e25` use the `stores` fixtures and follow the same order; `e24` and `e25` +cover `E_AMBIGUOUS_PATH` (Section 8, row 17). A case passes when an implementation loads the fixture named in `expected.json`, submits `query.json`, and either returns a result equal to @@ -67,14 +70,16 @@ Each `expected.json` may set `fixture` to one of: `retail` matches Appendix B.1–B.2 and B.4–B.5: every order, return, and visit matches a customer, so no NULL groups arise from unmatched home rows. -`stores` matches Appendix B.3 without the closing-date relationship. Some -`store_sales` rows have a NULL `customer_id`, and one customer has a NULL -`region`, so a `LEFT JOIN` places amounts in a NULL group (Sections 4 and 5.5, -S1). An `INNER JOIN` would drop those rows. +`stores` matches Appendix B.3 without the closing-date relationship. Sale SS4 +has a NULL `customer_id`, and customer C3 has a NULL `region`, so a `LEFT JOIN` +places both amounts in the NULL region group (Section 5.4; Section 6, S1). An +`INNER JOIN` would drop SS4. `stores_ambiguous` adds `store` to `date_dim` through `closing_date_id`, so -`store_sales` has two paths to `date_dim`. Cases `e22` and `e23` use this -fixture; `a19` and `a20` are the same queries on `stores` and succeed. +`store_sales` has two paths to `date_dim`. Cases `e24` and `e25` use this +fixture; `a19` and `a20` are the same queries on `stores` and succeed. `a21` +also uses this fixture and succeeds: `E_AMBIGUOUS_PATH` applies only to paths +between datasets that the lowering joins. Case files ---------- diff --git a/compliance/wide_table/cases/a17_unmatched_home_null_group/expected.json b/compliance/wide_table/cases/a17_unmatched_home_null_group/expected.json index 1fa2c46f..7c9fd2fa 100644 --- a/compliance/wide_table/cases/a17_unmatched_home_null_group/expected.json +++ b/compliance/wide_table/cases/a17_unmatched_home_null_group/expected.json @@ -2,8 +2,8 @@ "fixture": "stores", "title": "Unmatched home rows and NULL dimension keys form a NULL group", "question": "What is the sales amount by customer region?", - "behavior": "The branch LEFT JOINs customers from store_sales. SS4 has no customer, and C3 has a NULL region; both place their amounts in the NULL region group (25 + 40). An INNER JOIN would drop them. S1; Sections 4 and 5.5.", - "spec": ["4", "5.4", "5.5"], + "behavior": "The branch LEFT JOINs customers from store_sales. SS4 has no customer, and SS5's customer C3 has a NULL region, so both amounts are in the NULL region group (25 + 40). An INNER JOIN would drop SS4 and leave 40. Section 6, S1.", + "spec": ["4", "5.4", "6"], "columns": ["region", "total_sales"], "rows": [ ["EAST", 150], diff --git a/compliance/wide_table/cases/a18_anchor_with_metric/expected.json b/compliance/wide_table/cases/a18_anchor_with_metric/expected.json index 9d27781b..54985f45 100644 --- a/compliance/wide_table/cases/a18_anchor_with_metric/expected.json +++ b/compliance/wide_table/cases/a18_anchor_with_metric/expected.json @@ -2,7 +2,7 @@ "fixture": "stores", "title": "A metric makes an otherwise unanchored query valid", "question": "What is the sales amount by item brand and store state?", - "behavior": "Without a metric, item and store cannot reach each other (e25). store_sales reaches both, so the query is valid. Appendix B.3.", + "behavior": "Without a metric, item and store cannot reach each other (e23). store_sales reaches both, so the query is valid. Appendix B.3.", "spec": ["5.3", "5.6", "B.3"], "columns": ["brand", "state", "total_sales"], "rows": [ diff --git a/compliance/wide_table/cases/a19_sales_by_year/expected.json b/compliance/wide_table/cases/a19_sales_by_year/expected.json index ff974ea4..a3cccfc4 100644 --- a/compliance/wide_table/cases/a19_sales_by_year/expected.json +++ b/compliance/wide_table/cases/a19_sales_by_year/expected.json @@ -2,7 +2,7 @@ "fixture": "stores", "title": "One path from store_sales to date_dim", "question": "What is the sales amount by year?", - "behavior": "store_sales reaches date_dim only through sale_date_id, so the query is valid. The same query against stores_ambiguous raises E_AMBIGUOUS_PATH (e22).", + "behavior": "store_sales reaches date_dim only through sale_date_id, so the query is valid. The same query against stores_ambiguous raises E_AMBIGUOUS_PATH (e24).", "spec": ["4", "5.4", "B.3"], "columns": ["year", "total_sales"], "rows": [ diff --git a/compliance/wide_table/cases/a20_filter_on_sale_year/expected.json b/compliance/wide_table/cases/a20_filter_on_sale_year/expected.json index 42c1e699..33991ea2 100644 --- a/compliance/wide_table/cases/a20_filter_on_sale_year/expected.json +++ b/compliance/wide_table/cases/a20_filter_on_sale_year/expected.json @@ -2,7 +2,7 @@ "fixture": "stores", "title": "A filter on date_dim with one path", "question": "What is the total sales amount for year 2024?", - "behavior": "store_sales reaches date_dim only through sale_date_id, so the filter applies. Sales in 2024 are 200 + 50 + 40 = 290. The same query against stores_ambiguous raises E_AMBIGUOUS_PATH (e23).", + "behavior": "store_sales reaches date_dim only through sale_date_id, so the filter applies. Sales in 2024 are 200 + 50 + 40 = 290. The same query against stores_ambiguous raises E_AMBIGUOUS_PATH (e25).", "spec": ["4", "5.3", "5.4", "B.3"], "columns": ["total_sales"], "rows": [ diff --git a/compliance/wide_table/cases/a21_single_path_on_ambiguous_model/expected.json b/compliance/wide_table/cases/a21_single_path_on_ambiguous_model/expected.json new file mode 100644 index 00000000..6e86af89 --- /dev/null +++ b/compliance/wide_table/cases/a21_single_path_on_ambiguous_model/expected.json @@ -0,0 +1,12 @@ +{ + "fixture": "stores_ambiguous", + "title": "A second path elsewhere in the model does not make a query ambiguous", + "question": "What is the return amount by year?", + "behavior": "store_returns reaches date_dim only through return_date_id. store_sales has two paths to date_dim, but this query does not join store_sales or store, so it is valid. E_AMBIGUOUS_PATH applies only to paths between datasets that the lowering joins (Section 8, row 17).", + "spec": ["4", "5.4", "8", "B.3"], + "columns": ["year", "total_returns"], + "rows": [ + [2023, 10], + [2024, 5] + ] +} diff --git a/compliance/wide_table/cases/a21_single_path_on_ambiguous_model/query.json b/compliance/wide_table/cases/a21_single_path_on_ambiguous_model/query.json new file mode 100644 index 00000000..c359c4ce --- /dev/null +++ b/compliance/wide_table/cases/a21_single_path_on_ambiguous_model/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["date_dim.year"], + "metrics": ["store_returns.total_returns"] +} diff --git a/compliance/wide_table/cases/e24_no_path_stores/expected.json b/compliance/wide_table/cases/e22_no_path_stores/expected.json similarity index 100% rename from compliance/wide_table/cases/e24_no_path_stores/expected.json rename to compliance/wide_table/cases/e22_no_path_stores/expected.json diff --git a/compliance/wide_table/cases/e24_no_path_stores/query.json b/compliance/wide_table/cases/e22_no_path_stores/query.json similarity index 100% rename from compliance/wide_table/cases/e24_no_path_stores/query.json rename to compliance/wide_table/cases/e22_no_path_stores/query.json diff --git a/compliance/wide_table/cases/e25_no_anchor_stores/expected.json b/compliance/wide_table/cases/e23_no_anchor_stores/expected.json similarity index 100% rename from compliance/wide_table/cases/e25_no_anchor_stores/expected.json rename to compliance/wide_table/cases/e23_no_anchor_stores/expected.json diff --git a/compliance/wide_table/cases/e25_no_anchor_stores/query.json b/compliance/wide_table/cases/e23_no_anchor_stores/query.json similarity index 100% rename from compliance/wide_table/cases/e25_no_anchor_stores/query.json rename to compliance/wide_table/cases/e23_no_anchor_stores/query.json diff --git a/compliance/wide_table/cases/e22_ambiguous_path_dimension/expected.json b/compliance/wide_table/cases/e24_ambiguous_path_dimension/expected.json similarity index 100% rename from compliance/wide_table/cases/e22_ambiguous_path_dimension/expected.json rename to compliance/wide_table/cases/e24_ambiguous_path_dimension/expected.json diff --git a/compliance/wide_table/cases/e22_ambiguous_path_dimension/query.json b/compliance/wide_table/cases/e24_ambiguous_path_dimension/query.json similarity index 100% rename from compliance/wide_table/cases/e22_ambiguous_path_dimension/query.json rename to compliance/wide_table/cases/e24_ambiguous_path_dimension/query.json diff --git a/compliance/wide_table/cases/e23_ambiguous_path_filter/expected.json b/compliance/wide_table/cases/e25_ambiguous_path_filter/expected.json similarity index 100% rename from compliance/wide_table/cases/e23_ambiguous_path_filter/expected.json rename to compliance/wide_table/cases/e25_ambiguous_path_filter/expected.json diff --git a/compliance/wide_table/cases/e23_ambiguous_path_filter/query.json b/compliance/wide_table/cases/e25_ambiguous_path_filter/query.json similarity index 100% rename from compliance/wide_table/cases/e23_ambiguous_path_filter/query.json rename to compliance/wide_table/cases/e25_ambiguous_path_filter/query.json diff --git a/compliance/wide_table/retail/retail.sql b/compliance/wide_table/retail/retail.sql index 2256022e..c78df7a7 100644 --- a/compliance/wide_table/retail/retail.sql +++ b/compliance/wide_table/retail/retail.sql @@ -18,9 +18,10 @@ -- ============================================================================ -- Data: customers, orders, returns, visits, and tickets -- --- Shared input data for the wide table compliance cases in ../cases/. Load --- this file before a case runs. Do not change the values: the expected results --- of all cases depend on them. +-- Shared input data for the wide table compliance cases in ../cases/ that use +-- the retail fixture (../README.md, "Fixtures"). Load this file before such a +-- case runs. Do not change the values: the expected results of those cases +-- depend on them. -- -- The rows of customers, orders, returns, and visits are the tables of -- core-spec/wide_table_semantics.md, Appendix B.1 and B.2. The specification diff --git a/compliance/wide_table/retail/retail_model.ossie.yaml b/compliance/wide_table/retail/retail_model.ossie.yaml index fc48337e..d4462acc 100644 --- a/compliance/wide_table/retail/retail_model.ossie.yaml +++ b/compliance/wide_table/retail/retail_model.ossie.yaml @@ -18,9 +18,9 @@ # yaml-language-server: $schema=../../../core-spec/ossie-schema.json # # Ossie semantic model over retail.sql, for the wide table compliance cases in -# ../cases/. It is the model of core-spec/wide_table_semantics.md, Appendix B: -# orders, returns, and visits relate to customers, and tickets relates to no -# dataset (B.4). +# ../cases/ that use the retail fixture. It is the model of +# core-spec/wide_table_semantics.md, Appendix B: orders, returns, and visits +# relate to customers, and tickets relates to no dataset (B.4). # # Every dataset-scoped metric is one component (Section 5.2). The model-scoped # metric revenue_per_customer has two components, as in Section 5.2. It casts diff --git a/compliance/wide_table/stores/stores.sql b/compliance/wide_table/stores/stores.sql index 831151d0..41b4889e 100644 --- a/compliance/wide_table/stores/stores.sql +++ b/compliance/wide_table/stores/stores.sql @@ -22,7 +22,10 @@ -- ../cases/. Load this file before a stores case runs. Do not change the -- values: the expected results depend on them. -- --- SS4 has no customer; C3 has a NULL region (NULL groups / S1). +-- Appendix B.3 names the datasets and relationships but gives no rows, so +-- the rows here are chosen for the cases. SS4 has no customer, and C3 has a +-- NULL region (Section 6, S1). The year column is d_year because YEAR is a +-- reserved word in standard SQL; the model names the field year. -- stores_ambiguous_model adds store → date_dim via closing_date_id. -- ============================================================================ @@ -31,7 +34,7 @@ CREATE SCHEMA stores; CREATE TABLE stores.date_dim ( date_id VARCHAR NOT NULL PRIMARY KEY, - year INTEGER NOT NULL + d_year INTEGER NOT NULL ); INSERT INTO stores.date_dim VALUES diff --git a/compliance/wide_table/stores/stores_ambiguous_model.ossie.yaml b/compliance/wide_table/stores/stores_ambiguous_model.ossie.yaml index 12b115ee..f9daadcf 100644 --- a/compliance/wide_table/stores/stores_ambiguous_model.ossie.yaml +++ b/compliance/wide_table/stores/stores_ambiguous_model.ossie.yaml @@ -35,7 +35,7 @@ datasets: - name: year datatype: Integer expression: - sql: year + sql: d_year - name: item source: stores.item diff --git a/compliance/wide_table/stores/stores_model.ossie.yaml b/compliance/wide_table/stores/stores_model.ossie.yaml index 00937297..608d6c2b 100644 --- a/compliance/wide_table/stores/stores_model.ossie.yaml +++ b/compliance/wide_table/stores/stores_model.ossie.yaml @@ -35,7 +35,7 @@ datasets: - name: year datatype: Integer expression: - sql: year + sql: d_year - name: item source: stores.item