Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 17 additions & 12 deletions compliance/wide_table/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,9 +47,10 @@ Layout
| `cases/<case>/query.json` | Query under test, in the JSON binding of Section 3.7 |
| `cases/<case>/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
Expand All @@ -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
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dimensions": ["date_dim.year"],
"metrics": ["store_returns.total_returns"]
}
7 changes: 4 additions & 3 deletions compliance/wide_table/retail/retail.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions compliance/wide_table/retail/retail_model.ossie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions compliance/wide_table/stores/stores.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-- ============================================================================

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ datasets:
- name: year
datatype: Integer
expression:
sql: year
sql: d_year

- name: item
source: stores.item
Expand Down
2 changes: 1 addition & 1 deletion compliance/wide_table/stores/stores_model.ossie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ datasets:
- name: year
datatype: Integer
expression:
sql: year
sql: d_year

- name: item
source: stores.item
Expand Down
Loading