From c6f5d0bfe6ab1c2b909f47603b0100733262159a Mon Sep 17 00:00:00 2001 From: Alex Kosachev Date: Wed, 11 Nov 2026 14:42:49 +0800 Subject: [PATCH 1/2] feat(compliance): add Layer 3 wide table query cases 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. --- compliance/README.md | 2 + compliance/wide_table/README.md | 104 ++++++++++ .../cases/a01_shared_dimension/expected.json | 12 ++ .../cases/a01_shared_dimension/query.json | 4 + .../cases/a02_count_empty_input/expected.json | 12 ++ .../cases/a02_count_empty_input/query.json | 4 + .../cases/a03_three_branches/expected.json | 12 ++ .../cases/a03_three_branches/query.json | 4 + .../a04_filter_on_dimension/expected.json | 11 ++ .../cases/a04_filter_on_dimension/query.json | 5 + .../a05_groups_from_orders/expected.json | 11 ++ .../cases/a05_groups_from_orders/query.json | 4 + .../a06_groups_from_returns/expected.json | 11 ++ .../cases/a06_groups_from_returns/query.json | 4 + .../cases/a07_dimension_only/expected.json | 12 ++ .../cases/a07_dimension_only/query.json | 3 + .../a08_model_metric_components/expected.json | 10 + .../a08_model_metric_components/query.json | 3 + .../cases/a09_aliases/expected.json | 11 ++ .../wide_table/cases/a09_aliases/query.json | 4 + .../expected.json | 10 + .../a10_filter_without_dimension/query.json | 4 + .../a11_filter_on_home_dataset/expected.json | 11 ++ .../a11_filter_on_home_dataset/query.json | 5 + .../a12_anchor_from_dimensions/expected.json | 11 ++ .../a12_anchor_from_dimensions/query.json | 4 + .../expected.json | 8 + .../query.json | 5 + .../expected.json | 10 + .../query.json | 4 + .../expected.json | 10 + .../a15_unconnected_filter_false/query.json | 4 + .../expected.json | 7 + .../e01_invalid_query_unknown_key/query.json | 4 + .../e02_invalid_query_null/expected.json | 7 + .../cases/e02_invalid_query_null/query.json | 4 + .../e03_empty_aggregation_query/expected.json | 7 + .../e03_empty_aggregation_query/query.json | 3 + .../cases/e04_name_not_found/expected.json | 7 + .../cases/e04_name_not_found/query.json | 3 + .../e05_metric_in_dimensions/expected.json | 7 + .../cases/e05_metric_in_dimensions/query.json | 3 + .../cases/e06_field_in_metrics/expected.json | 7 + .../cases/e06_field_in_metrics/query.json | 3 + .../e07_aggregate_in_filter/expected.json | 7 + .../cases/e07_aggregate_in_filter/query.json | 4 + .../cases/e08_window_in_filter/expected.json | 7 + .../cases/e08_window_in_filter/query.json | 4 + .../e09_cross_dataset_filter/expected.json | 7 + .../cases/e09_cross_dataset_filter/query.json | 4 + .../cases/e10_name_collision/expected.json | 7 + .../cases/e10_name_collision/query.json | 3 + .../expected.json | 7 + .../query.json | 3 + .../cases/e12_windowed_metric/expected.json | 7 + .../cases/e12_windowed_metric/query.json | 3 + .../expected.json | 7 + .../e13_measure_grain_two_datasets/query.json | 3 + .../expected.json | 7 + .../e14_measure_grain_no_dataset/query.json | 3 + .../cases/e15_no_path/expected.json | 7 + .../wide_table/cases/e15_no_path/query.json | 4 + .../expected.json | 7 + .../query.json | 4 + .../cases/e17_no_anchor/expected.json | 7 + .../wide_table/cases/e17_no_anchor/query.json | 3 + .../e18_filter_path_from_metric/expected.json | 7 + .../e18_filter_path_from_metric/query.json | 5 + .../e19_filter_path_from_anchor/expected.json | 7 + .../e19_filter_path_from_anchor/query.json | 4 + .../expected.json | 7 + .../e20_order_invalid_before_name/query.json | 4 + .../expected.json | 7 + .../e21_order_name_before_filter/query.json | 4 + compliance/wide_table/retail/retail.sql | 78 ++++++++ .../wide_table/retail/retail_model.ossie.yaml | 184 ++++++++++++++++++ 76 files changed, 813 insertions(+) create mode 100644 compliance/wide_table/README.md create mode 100644 compliance/wide_table/cases/a01_shared_dimension/expected.json create mode 100644 compliance/wide_table/cases/a01_shared_dimension/query.json create mode 100644 compliance/wide_table/cases/a02_count_empty_input/expected.json create mode 100644 compliance/wide_table/cases/a02_count_empty_input/query.json create mode 100644 compliance/wide_table/cases/a03_three_branches/expected.json create mode 100644 compliance/wide_table/cases/a03_three_branches/query.json create mode 100644 compliance/wide_table/cases/a04_filter_on_dimension/expected.json create mode 100644 compliance/wide_table/cases/a04_filter_on_dimension/query.json create mode 100644 compliance/wide_table/cases/a05_groups_from_orders/expected.json create mode 100644 compliance/wide_table/cases/a05_groups_from_orders/query.json create mode 100644 compliance/wide_table/cases/a06_groups_from_returns/expected.json create mode 100644 compliance/wide_table/cases/a06_groups_from_returns/query.json create mode 100644 compliance/wide_table/cases/a07_dimension_only/expected.json create mode 100644 compliance/wide_table/cases/a07_dimension_only/query.json create mode 100644 compliance/wide_table/cases/a08_model_metric_components/expected.json create mode 100644 compliance/wide_table/cases/a08_model_metric_components/query.json create mode 100644 compliance/wide_table/cases/a09_aliases/expected.json create mode 100644 compliance/wide_table/cases/a09_aliases/query.json create mode 100644 compliance/wide_table/cases/a10_filter_without_dimension/expected.json create mode 100644 compliance/wide_table/cases/a10_filter_without_dimension/query.json create mode 100644 compliance/wide_table/cases/a11_filter_on_home_dataset/expected.json create mode 100644 compliance/wide_table/cases/a11_filter_on_home_dataset/query.json create mode 100644 compliance/wide_table/cases/a12_anchor_from_dimensions/expected.json create mode 100644 compliance/wide_table/cases/a12_anchor_from_dimensions/query.json create mode 100644 compliance/wide_table/cases/a13_filter_false_with_dimension/expected.json create mode 100644 compliance/wide_table/cases/a13_filter_false_with_dimension/query.json create mode 100644 compliance/wide_table/cases/a14_filter_false_without_dimension/expected.json create mode 100644 compliance/wide_table/cases/a14_filter_false_without_dimension/query.json create mode 100644 compliance/wide_table/cases/a15_unconnected_filter_false/expected.json create mode 100644 compliance/wide_table/cases/a15_unconnected_filter_false/query.json create mode 100644 compliance/wide_table/cases/e01_invalid_query_unknown_key/expected.json create mode 100644 compliance/wide_table/cases/e01_invalid_query_unknown_key/query.json create mode 100644 compliance/wide_table/cases/e02_invalid_query_null/expected.json create mode 100644 compliance/wide_table/cases/e02_invalid_query_null/query.json create mode 100644 compliance/wide_table/cases/e03_empty_aggregation_query/expected.json create mode 100644 compliance/wide_table/cases/e03_empty_aggregation_query/query.json create mode 100644 compliance/wide_table/cases/e04_name_not_found/expected.json create mode 100644 compliance/wide_table/cases/e04_name_not_found/query.json create mode 100644 compliance/wide_table/cases/e05_metric_in_dimensions/expected.json create mode 100644 compliance/wide_table/cases/e05_metric_in_dimensions/query.json create mode 100644 compliance/wide_table/cases/e06_field_in_metrics/expected.json create mode 100644 compliance/wide_table/cases/e06_field_in_metrics/query.json create mode 100644 compliance/wide_table/cases/e07_aggregate_in_filter/expected.json create mode 100644 compliance/wide_table/cases/e07_aggregate_in_filter/query.json create mode 100644 compliance/wide_table/cases/e08_window_in_filter/expected.json create mode 100644 compliance/wide_table/cases/e08_window_in_filter/query.json create mode 100644 compliance/wide_table/cases/e09_cross_dataset_filter/expected.json create mode 100644 compliance/wide_table/cases/e09_cross_dataset_filter/query.json create mode 100644 compliance/wide_table/cases/e10_name_collision/expected.json create mode 100644 compliance/wide_table/cases/e10_name_collision/query.json create mode 100644 compliance/wide_table/cases/e11_unaggregated_field_in_metric/expected.json create mode 100644 compliance/wide_table/cases/e11_unaggregated_field_in_metric/query.json create mode 100644 compliance/wide_table/cases/e12_windowed_metric/expected.json create mode 100644 compliance/wide_table/cases/e12_windowed_metric/query.json create mode 100644 compliance/wide_table/cases/e13_measure_grain_two_datasets/expected.json create mode 100644 compliance/wide_table/cases/e13_measure_grain_two_datasets/query.json create mode 100644 compliance/wide_table/cases/e14_measure_grain_no_dataset/expected.json create mode 100644 compliance/wide_table/cases/e14_measure_grain_no_dataset/query.json create mode 100644 compliance/wide_table/cases/e15_no_path/expected.json create mode 100644 compliance/wide_table/cases/e15_no_path/query.json create mode 100644 compliance/wide_table/cases/e16_partial_dimension_reachability/expected.json create mode 100644 compliance/wide_table/cases/e16_partial_dimension_reachability/query.json create mode 100644 compliance/wide_table/cases/e17_no_anchor/expected.json create mode 100644 compliance/wide_table/cases/e17_no_anchor/query.json create mode 100644 compliance/wide_table/cases/e18_filter_path_from_metric/expected.json create mode 100644 compliance/wide_table/cases/e18_filter_path_from_metric/query.json create mode 100644 compliance/wide_table/cases/e19_filter_path_from_anchor/expected.json create mode 100644 compliance/wide_table/cases/e19_filter_path_from_anchor/query.json create mode 100644 compliance/wide_table/cases/e20_order_invalid_before_name/expected.json create mode 100644 compliance/wide_table/cases/e20_order_invalid_before_name/query.json create mode 100644 compliance/wide_table/cases/e21_order_name_before_filter/expected.json create mode 100644 compliance/wide_table/cases/e21_order_name_before_filter/query.json create mode 100644 compliance/wide_table/retail/retail.sql create mode 100644 compliance/wide_table/retail/retail_model.ossie.yaml diff --git a/compliance/README.md b/compliance/README.md index e6003b54c..85f25f58d 100644 --- a/compliance/README.md +++ b/compliance/README.md @@ -23,3 +23,5 @@ This is for compliance tests model survives a round trip through each converter. - [`query/`](query/): query test cases for the [Relational Query Interface](../core-spec/relational_semantics.md). +- [`wide_table/`](wide_table/): query test cases for the + [Wide Table Query Interface](../core-spec/wide_table_semantics.md). diff --git a/compliance/wide_table/README.md b/compliance/wide_table/README.md new file mode 100644 index 000000000..dbf0208ee --- /dev/null +++ b/compliance/wide_table/README.md @@ -0,0 +1,104 @@ + + +Wide table compliance tests +=========================== + +Compliance tests for the +[Wide Table Query Interface](../../core-spec/wide_table_semantics.md) +(Layer 3). All cases use the same data and Ossie model. 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. + +The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY are to be +interpreted as described in BCP 14 +([RFC 2119](https://www.rfc-editor.org/rfc/rfc2119), +[RFC 8174](https://www.rfc-editor.org/rfc/rfc8174)) when they appear in +uppercase. + +Layout +------ + +| Path | Contents | +|------|----------| +| [`retail/retail.sql`](retail/retail.sql) | Schema and data: customers, orders, returns, visits, and tickets | +| [`retail/retail_model.ossie.yaml`](retail/retail_model.ossie.yaml) | Ossie model with relationships and metrics | +| `cases//query.json` | Query under test, in the JSON binding of Section 3.7 | +| `cases//expected.json` | Expected result or error | + +Cases `a*` return rows. Cases `e*` raise an error; they follow the order of +the table in Section 8, and `e20` and `e21` test that order. + +A case passes when an implementation loads the data and the model, submits +`query.json`, and either returns a result equal to the expected rows (see +"Comparing results") or raises the expected error. + +Case files +---------- + +`query.json` is the query as a consumer submits it. It has only the parts of +Section 3.2. + +`expected.json` describes the case and its result: + +- `title`: what the case shows. +- `question`: what the query asks, in English. It helps a reader; the query is + the ground truth. +- `behavior`: the rule under test, and why the result has its values. +- `spec`: the sections of the specification that define the result. +- `columns` and `rows`: the expected result, with the output names of Section + 3.3 in query order. Or `error`: the code from Section 8 that the engine + MUST raise. + +```json +{ + "title": "Groups come from the metric's dataset", + "question": "What is the order amount by customer region?", + "behavior": "One branch from orders. NORTH has no orders, so it is not a group.", + "spec": ["5.4", "6.1"], + "columns": ["region", "total_revenue"], + "rows": [ + ["EAST", 350], + ["WEST", 300] + ] +} +``` + +For codes 13, 14, and 16, Section 8 also requires the error to identify the +dimension or the filter, and a metric or the anchor that does not reach its +dataset. `behavior` names them. How an engine reports them depends on its +binding, so the cases check only the code. + +Result semantics +---------------- + +The rules of [`../query/README.md`](../query/README.md), "Result semantics", +apply. For example, `SUM` over no rows is NULL and `COUNT(*)` over no rows is +0, which gives the empty-input values of Section 5.2. + +Comparing results +----------------- + +Results are compared as in [`../query/README.md`](../query/README.md), +"Comparing results". Rows have no defined order (Section 3.6). In +`expected.json`: + +- A JSON number without a fraction or an exponent is an exact numeric. Any + other JSON number is an approximate numeric. +- A JSON `null` is SQL NULL. diff --git a/compliance/wide_table/cases/a01_shared_dimension/expected.json b/compliance/wide_table/cases/a01_shared_dimension/expected.json new file mode 100644 index 000000000..8e8a7bae4 --- /dev/null +++ b/compliance/wide_table/cases/a01_shared_dimension/expected.json @@ -0,0 +1,12 @@ +{ + "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.", + "spec": ["1.3", "5.4", "5.5"], + "columns": ["region", "total_revenue", "total_returns"], + "rows": [ + ["EAST", 350, 25], + ["WEST", 300, null], + ["NORTH", null, 10] + ] +} diff --git a/compliance/wide_table/cases/a01_shared_dimension/query.json b/compliance/wide_table/cases/a01_shared_dimension/query.json new file mode 100644 index 000000000..1af10e1a6 --- /dev/null +++ b/compliance/wide_table/cases/a01_shared_dimension/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue", "returns.total_returns"] +} diff --git a/compliance/wide_table/cases/a02_count_empty_input/expected.json b/compliance/wide_table/cases/a02_count_empty_input/expected.json new file mode 100644 index 000000000..7e340045d --- /dev/null +++ b/compliance/wide_table/cases/a02_count_empty_input/expected.json @@ -0,0 +1,12 @@ +{ + "title": "A missing branch row takes the empty-input value of COUNT(*)", + "question": "What is the order amount and the number of returns by customer region?", + "behavior": "WEST has orders and no returns. Its return_count is the empty-input value of COUNT(*), 0, not NULL.", + "spec": ["5.2", "5.5", "B.1"], + "columns": ["region", "total_revenue", "return_count"], + "rows": [ + ["EAST", 350, 1], + ["WEST", 300, 0], + ["NORTH", null, 1] + ] +} diff --git a/compliance/wide_table/cases/a02_count_empty_input/query.json b/compliance/wide_table/cases/a02_count_empty_input/query.json new file mode 100644 index 000000000..575fa1632 --- /dev/null +++ b/compliance/wide_table/cases/a02_count_empty_input/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue", "returns.return_count"] +} diff --git a/compliance/wide_table/cases/a03_three_branches/expected.json b/compliance/wide_table/cases/a03_three_branches/expected.json new file mode 100644 index 000000000..8ba16a57f --- /dev/null +++ b/compliance/wide_table/cases/a03_three_branches/expected.json @@ -0,0 +1,12 @@ +{ + "title": "Three branches give each key once", + "question": "What are the order amount, return amount, and number of visits by customer region?", + "behavior": "Each branch supplies some regions. NORTH is in the returns and visits branches but not in the orders branch, and appears once.", + "spec": ["5.5", "B.2"], + "columns": ["region", "total_revenue", "total_returns", "visit_count"], + "rows": [ + ["EAST", 350, 25, 0], + ["WEST", 300, null, 1], + ["NORTH", null, 10, 2] + ] +} diff --git a/compliance/wide_table/cases/a03_three_branches/query.json b/compliance/wide_table/cases/a03_three_branches/query.json new file mode 100644 index 000000000..b8b12d2d4 --- /dev/null +++ b/compliance/wide_table/cases/a03_three_branches/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue", "returns.total_returns", "visits.visit_count"] +} diff --git a/compliance/wide_table/cases/a04_filter_on_dimension/expected.json b/compliance/wide_table/cases/a04_filter_on_dimension/expected.json new file mode 100644 index 000000000..07ca7bcd3 --- /dev/null +++ b/compliance/wide_table/cases/a04_filter_on_dimension/expected.json @@ -0,0 +1,11 @@ +{ + "title": "A filter on the dimension dataset applies to every branch", + "question": "What are the order and return amounts by customer region, outside EAST?", + "behavior": "Both metrics reach customers, so the filter applies to both branches. The filter removes groups and adds none.", + "spec": ["3.4", "5.3", "6", "B.1"], + "columns": ["region", "total_revenue", "total_returns"], + "rows": [ + ["WEST", 300, null], + ["NORTH", null, 10] + ] +} diff --git a/compliance/wide_table/cases/a04_filter_on_dimension/query.json b/compliance/wide_table/cases/a04_filter_on_dimension/query.json new file mode 100644 index 000000000..293b39e5d --- /dev/null +++ b/compliance/wide_table/cases/a04_filter_on_dimension/query.json @@ -0,0 +1,5 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue", "returns.total_returns"], + "filter": "customers.region <> 'EAST'" +} diff --git a/compliance/wide_table/cases/a05_groups_from_orders/expected.json b/compliance/wide_table/cases/a05_groups_from_orders/expected.json new file mode 100644 index 000000000..8f3fce391 --- /dev/null +++ b/compliance/wide_table/cases/a05_groups_from_orders/expected.json @@ -0,0 +1,11 @@ +{ + "title": "Groups come from the metric's dataset", + "question": "What is the order amount by customer region?", + "behavior": "One branch from orders. NORTH has no orders, so it is not a group.", + "spec": ["5.4", "6.1"], + "columns": ["region", "total_revenue"], + "rows": [ + ["EAST", 350], + ["WEST", 300] + ] +} diff --git a/compliance/wide_table/cases/a05_groups_from_orders/query.json b/compliance/wide_table/cases/a05_groups_from_orders/query.json new file mode 100644 index 000000000..50e5892be --- /dev/null +++ b/compliance/wide_table/cases/a05_groups_from_orders/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue"] +} diff --git a/compliance/wide_table/cases/a06_groups_from_returns/expected.json b/compliance/wide_table/cases/a06_groups_from_returns/expected.json new file mode 100644 index 000000000..51447d12e --- /dev/null +++ b/compliance/wide_table/cases/a06_groups_from_returns/expected.json @@ -0,0 +1,11 @@ +{ + "title": "Another metric gives other groups", + "question": "What is the return amount by customer region?", + "behavior": "One branch from returns. WEST has no returns, so it is not a group.", + "spec": ["5.4", "6.1"], + "columns": ["region", "total_returns"], + "rows": [ + ["EAST", 25], + ["NORTH", 10] + ] +} diff --git a/compliance/wide_table/cases/a06_groups_from_returns/query.json b/compliance/wide_table/cases/a06_groups_from_returns/query.json new file mode 100644 index 000000000..bd76907ec --- /dev/null +++ b/compliance/wide_table/cases/a06_groups_from_returns/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["returns.total_returns"] +} diff --git a/compliance/wide_table/cases/a07_dimension_only/expected.json b/compliance/wide_table/cases/a07_dimension_only/expected.json new file mode 100644 index 000000000..d3b421391 --- /dev/null +++ b/compliance/wide_table/cases/a07_dimension_only/expected.json @@ -0,0 +1,12 @@ +{ + "title": "A query without metrics uses an anchor", + "question": "Which customer regions are there?", + "behavior": "The anchor is customers, the dataset of the only dimension. The result has its distinct regions.", + "spec": ["3.2", "5.6", "6.1"], + "columns": ["region"], + "rows": [ + ["EAST"], + ["WEST"], + ["NORTH"] + ] +} diff --git a/compliance/wide_table/cases/a07_dimension_only/query.json b/compliance/wide_table/cases/a07_dimension_only/query.json new file mode 100644 index 000000000..94105a805 --- /dev/null +++ b/compliance/wide_table/cases/a07_dimension_only/query.json @@ -0,0 +1,3 @@ +{ + "dimensions": ["customers.region"] +} diff --git a/compliance/wide_table/cases/a08_model_metric_components/expected.json b/compliance/wide_table/cases/a08_model_metric_components/expected.json new file mode 100644 index 000000000..f436a2c22 --- /dev/null +++ b/compliance/wide_table/cases/a08_model_metric_components/expected.json @@ -0,0 +1,10 @@ +{ + "title": "Each component of a model-scoped metric aggregates its own dataset", + "question": "What is the order amount per customer?", + "behavior": "The metric has a component on orders and one on customers. Each is a branch of its own, so the customer count includes C4, which has no orders: 650 / 4.", + "spec": ["5.2", "5.5"], + "columns": ["revenue_per_customer"], + "rows": [ + [162.5] + ] +} diff --git a/compliance/wide_table/cases/a08_model_metric_components/query.json b/compliance/wide_table/cases/a08_model_metric_components/query.json new file mode 100644 index 000000000..e3ff7271a --- /dev/null +++ b/compliance/wide_table/cases/a08_model_metric_components/query.json @@ -0,0 +1,3 @@ +{ + "metrics": ["revenue_per_customer"] +} diff --git a/compliance/wide_table/cases/a09_aliases/expected.json b/compliance/wide_table/cases/a09_aliases/expected.json new file mode 100644 index 000000000..518a05ea3 --- /dev/null +++ b/compliance/wide_table/cases/a09_aliases/expected.json @@ -0,0 +1,11 @@ +{ + "title": "Aliases name the output columns", + "question": "What is the order amount by customer region?", + "behavior": "The object form gives each entry an alias, and the alias is its output name.", + "spec": ["3.3", "3.6", "3.7"], + "columns": ["area", "revenue"], + "rows": [ + ["EAST", 350], + ["WEST", 300] + ] +} diff --git a/compliance/wide_table/cases/a09_aliases/query.json b/compliance/wide_table/cases/a09_aliases/query.json new file mode 100644 index 000000000..ea388272a --- /dev/null +++ b/compliance/wide_table/cases/a09_aliases/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": [{"field": "customers.region", "alias": "area"}], + "metrics": [{"metric": "orders.total_revenue", "alias": "revenue"}] +} diff --git a/compliance/wide_table/cases/a10_filter_without_dimension/expected.json b/compliance/wide_table/cases/a10_filter_without_dimension/expected.json new file mode 100644 index 000000000..42a27614a --- /dev/null +++ b/compliance/wide_table/cases/a10_filter_without_dimension/expected.json @@ -0,0 +1,10 @@ +{ + "title": "A filter on a dataset the metric reaches", + "question": "What is the order amount of customers in EAST?", + "behavior": "The branch from orders joins customers for the filter. Without dimensions, the result has one row.", + "spec": ["3.4", "5.4", "B.5"], + "columns": ["total_revenue"], + "rows": [ + [350] + ] +} diff --git a/compliance/wide_table/cases/a10_filter_without_dimension/query.json b/compliance/wide_table/cases/a10_filter_without_dimension/query.json new file mode 100644 index 000000000..54c292c5f --- /dev/null +++ b/compliance/wide_table/cases/a10_filter_without_dimension/query.json @@ -0,0 +1,4 @@ +{ + "metrics": ["orders.total_revenue"], + "filter": "customers.region = 'EAST'" +} diff --git a/compliance/wide_table/cases/a11_filter_on_home_dataset/expected.json b/compliance/wide_table/cases/a11_filter_on_home_dataset/expected.json new file mode 100644 index 000000000..b2b71fa22 --- /dev/null +++ b/compliance/wide_table/cases/a11_filter_on_home_dataset/expected.json @@ -0,0 +1,11 @@ +{ + "title": "A filter on the metric's own dataset", + "question": "What is the amount of orders over 100 by customer region?", + "behavior": "The filter removes O1 and O3 before aggregation.", + "spec": ["3.4", "5.4", "B.5"], + "columns": ["region", "total_revenue"], + "rows": [ + ["EAST", 200], + ["WEST", 300] + ] +} diff --git a/compliance/wide_table/cases/a11_filter_on_home_dataset/query.json b/compliance/wide_table/cases/a11_filter_on_home_dataset/query.json new file mode 100644 index 000000000..d475d96e2 --- /dev/null +++ b/compliance/wide_table/cases/a11_filter_on_home_dataset/query.json @@ -0,0 +1,5 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue"], + "filter": "orders.amount > 100" +} diff --git a/compliance/wide_table/cases/a12_anchor_from_dimensions/expected.json b/compliance/wide_table/cases/a12_anchor_from_dimensions/expected.json new file mode 100644 index 000000000..01b8840ba --- /dev/null +++ b/compliance/wide_table/cases/a12_anchor_from_dimensions/expected.json @@ -0,0 +1,11 @@ +{ + "title": "The anchor is the dimension dataset that reaches the others", + "question": "Which orders over 100 are there, with the region of their customer?", + "behavior": "orders reaches customers, and customers does not reach orders, so the anchor is orders.", + "spec": ["5.6", "B.5"], + "columns": ["order_id", "region"], + "rows": [ + ["O2", "EAST"], + ["O4", "WEST"] + ] +} diff --git a/compliance/wide_table/cases/a12_anchor_from_dimensions/query.json b/compliance/wide_table/cases/a12_anchor_from_dimensions/query.json new file mode 100644 index 000000000..d6bf897b9 --- /dev/null +++ b/compliance/wide_table/cases/a12_anchor_from_dimensions/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["orders.order_id", "customers.region"], + "filter": "orders.amount > 100" +} diff --git a/compliance/wide_table/cases/a13_filter_false_with_dimension/expected.json b/compliance/wide_table/cases/a13_filter_false_with_dimension/expected.json new file mode 100644 index 000000000..ed9f14c03 --- /dev/null +++ b/compliance/wide_table/cases/a13_filter_false_with_dimension/expected.json @@ -0,0 +1,8 @@ +{ + "title": "A filter that removes every row leaves no groups", + "question": "What is the order amount by customer region, when no order is kept?", + "behavior": "The branch has no rows, so there are no keys and no rows.", + "spec": ["3.4", "5.5", "B.5"], + "columns": ["region", "total_revenue"], + "rows": [] +} diff --git a/compliance/wide_table/cases/a13_filter_false_with_dimension/query.json b/compliance/wide_table/cases/a13_filter_false_with_dimension/query.json new file mode 100644 index 000000000..6d8ccd3c5 --- /dev/null +++ b/compliance/wide_table/cases/a13_filter_false_with_dimension/query.json @@ -0,0 +1,5 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue"], + "filter": "FALSE" +} diff --git a/compliance/wide_table/cases/a14_filter_false_without_dimension/expected.json b/compliance/wide_table/cases/a14_filter_false_without_dimension/expected.json new file mode 100644 index 000000000..367f8617f --- /dev/null +++ b/compliance/wide_table/cases/a14_filter_false_without_dimension/expected.json @@ -0,0 +1,10 @@ +{ + "title": "Without dimensions, the result has one row", + "question": "What is the order amount, when no order is kept?", + "behavior": "The only key is the empty tuple. The value is the empty-input value of SUM, NULL.", + "spec": ["3.6", "5.5", "B.5"], + "columns": ["total_revenue"], + "rows": [ + [null] + ] +} diff --git a/compliance/wide_table/cases/a14_filter_false_without_dimension/query.json b/compliance/wide_table/cases/a14_filter_false_without_dimension/query.json new file mode 100644 index 000000000..7fee68470 --- /dev/null +++ b/compliance/wide_table/cases/a14_filter_false_without_dimension/query.json @@ -0,0 +1,4 @@ +{ + "metrics": ["orders.total_revenue"], + "filter": "FALSE" +} diff --git a/compliance/wide_table/cases/a15_unconnected_filter_false/expected.json b/compliance/wide_table/cases/a15_unconnected_filter_false/expected.json new file mode 100644 index 000000000..ab3bae6bd --- /dev/null +++ b/compliance/wide_table/cases/a15_unconnected_filter_false/expected.json @@ -0,0 +1,10 @@ +{ + "title": "A filter without a dataset applies to unconnected metrics", + "question": "What are the order amount and the number of tickets, when no row is kept?", + "behavior": "FALSE reads no dataset, so it needs no path. Each metric takes its empty-input value: NULL for SUM, 0 for COUNT(*).", + "spec": ["3.4", "5.3", "B.4"], + "columns": ["total_revenue", "ticket_count"], + "rows": [ + [null, 0] + ] +} diff --git a/compliance/wide_table/cases/a15_unconnected_filter_false/query.json b/compliance/wide_table/cases/a15_unconnected_filter_false/query.json new file mode 100644 index 000000000..6d298d3e5 --- /dev/null +++ b/compliance/wide_table/cases/a15_unconnected_filter_false/query.json @@ -0,0 +1,4 @@ +{ + "metrics": ["orders.total_revenue", "tickets.ticket_count"], + "filter": "FALSE" +} diff --git a/compliance/wide_table/cases/e01_invalid_query_unknown_key/expected.json b/compliance/wide_table/cases/e01_invalid_query_unknown_key/expected.json new file mode 100644 index 000000000..2404ea85f --- /dev/null +++ b/compliance/wide_table/cases/e01_invalid_query_unknown_key/expected.json @@ -0,0 +1,7 @@ +{ + "title": "An unsupported part is malformed", + "question": "What is the order amount, limited to 10 rows?", + "behavior": "limit is not a part of this version. The engine rejects it rather than ignore it.", + "spec": ["3.5", "3.7", "8"], + "error": "E_INVALID_QUERY" +} diff --git a/compliance/wide_table/cases/e01_invalid_query_unknown_key/query.json b/compliance/wide_table/cases/e01_invalid_query_unknown_key/query.json new file mode 100644 index 000000000..52b237496 --- /dev/null +++ b/compliance/wide_table/cases/e01_invalid_query_unknown_key/query.json @@ -0,0 +1,4 @@ +{ + "metrics": ["orders.total_revenue"], + "limit": 10 +} diff --git a/compliance/wide_table/cases/e02_invalid_query_null/expected.json b/compliance/wide_table/cases/e02_invalid_query_null/expected.json new file mode 100644 index 000000000..1dc51a313 --- /dev/null +++ b/compliance/wide_table/cases/e02_invalid_query_null/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A null value is malformed", + "question": "What is the order amount, with a null filter?", + "behavior": "The JSON binding treats null values as malformed.", + "spec": ["3.7", "8"], + "error": "E_INVALID_QUERY" +} diff --git a/compliance/wide_table/cases/e02_invalid_query_null/query.json b/compliance/wide_table/cases/e02_invalid_query_null/query.json new file mode 100644 index 000000000..9aecd4772 --- /dev/null +++ b/compliance/wide_table/cases/e02_invalid_query_null/query.json @@ -0,0 +1,4 @@ +{ + "metrics": ["orders.total_revenue"], + "filter": null +} diff --git a/compliance/wide_table/cases/e03_empty_aggregation_query/expected.json b/compliance/wide_table/cases/e03_empty_aggregation_query/expected.json new file mode 100644 index 000000000..c8f1e7045 --- /dev/null +++ b/compliance/wide_table/cases/e03_empty_aggregation_query/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A query needs a dimension or a metric", + "question": "(A query with only a filter.)", + "behavior": "All parts are optional, but at least one dimension or metric is required.", + "spec": ["3.2", "8"], + "error": "E_EMPTY_AGGREGATION_QUERY" +} diff --git a/compliance/wide_table/cases/e03_empty_aggregation_query/query.json b/compliance/wide_table/cases/e03_empty_aggregation_query/query.json new file mode 100644 index 000000000..31a1eb307 --- /dev/null +++ b/compliance/wide_table/cases/e03_empty_aggregation_query/query.json @@ -0,0 +1,3 @@ +{ + "filter": "TRUE" +} diff --git a/compliance/wide_table/cases/e04_name_not_found/expected.json b/compliance/wide_table/cases/e04_name_not_found/expected.json new file mode 100644 index 000000000..56b55c6d4 --- /dev/null +++ b/compliance/wide_table/cases/e04_name_not_found/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A reference must resolve", + "question": "What is orders.no_such_metric?", + "behavior": "orders has no field or metric of that name.", + "spec": ["3.2", "8"], + "error": "E_NAME_NOT_FOUND" +} diff --git a/compliance/wide_table/cases/e04_name_not_found/query.json b/compliance/wide_table/cases/e04_name_not_found/query.json new file mode 100644 index 000000000..accaeaaf2 --- /dev/null +++ b/compliance/wide_table/cases/e04_name_not_found/query.json @@ -0,0 +1,3 @@ +{ + "metrics": ["orders.no_such_metric"] +} diff --git a/compliance/wide_table/cases/e05_metric_in_dimensions/expected.json b/compliance/wide_table/cases/e05_metric_in_dimensions/expected.json new file mode 100644 index 000000000..b659adf40 --- /dev/null +++ b/compliance/wide_table/cases/e05_metric_in_dimensions/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A dimension must name a field", + "question": "(A metric used as a dimension.)", + "behavior": "orders.total_revenue is a metric.", + "spec": ["3.2", "8"], + "error": "E_METRIC_IN_DIMENSIONS" +} diff --git a/compliance/wide_table/cases/e05_metric_in_dimensions/query.json b/compliance/wide_table/cases/e05_metric_in_dimensions/query.json new file mode 100644 index 000000000..e4d230eb1 --- /dev/null +++ b/compliance/wide_table/cases/e05_metric_in_dimensions/query.json @@ -0,0 +1,3 @@ +{ + "dimensions": ["orders.total_revenue"] +} diff --git a/compliance/wide_table/cases/e06_field_in_metrics/expected.json b/compliance/wide_table/cases/e06_field_in_metrics/expected.json new file mode 100644 index 000000000..d3861f4f3 --- /dev/null +++ b/compliance/wide_table/cases/e06_field_in_metrics/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A metric entry must name a metric", + "question": "(A field used as a metric.)", + "behavior": "orders.amount is a field.", + "spec": ["3.2", "8"], + "error": "E_FIELD_IN_METRICS" +} diff --git a/compliance/wide_table/cases/e06_field_in_metrics/query.json b/compliance/wide_table/cases/e06_field_in_metrics/query.json new file mode 100644 index 000000000..d72f3485c --- /dev/null +++ b/compliance/wide_table/cases/e06_field_in_metrics/query.json @@ -0,0 +1,3 @@ +{ + "metrics": ["orders.amount"] +} diff --git a/compliance/wide_table/cases/e07_aggregate_in_filter/expected.json b/compliance/wide_table/cases/e07_aggregate_in_filter/expected.json new file mode 100644 index 000000000..0ef5f162e --- /dev/null +++ b/compliance/wide_table/cases/e07_aggregate_in_filter/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A filter cannot contain an aggregate", + "question": "(A filter on an aggregate.)", + "behavior": "The filter applies to rows before aggregation.", + "spec": ["3.4", "8"], + "error": "E_AGGREGATE_IN_WHERE" +} diff --git a/compliance/wide_table/cases/e07_aggregate_in_filter/query.json b/compliance/wide_table/cases/e07_aggregate_in_filter/query.json new file mode 100644 index 000000000..7b083d7fb --- /dev/null +++ b/compliance/wide_table/cases/e07_aggregate_in_filter/query.json @@ -0,0 +1,4 @@ +{ + "metrics": ["orders.total_revenue"], + "filter": "SUM(orders.amount) > 100" +} diff --git a/compliance/wide_table/cases/e08_window_in_filter/expected.json b/compliance/wide_table/cases/e08_window_in_filter/expected.json new file mode 100644 index 000000000..cfb566d41 --- /dev/null +++ b/compliance/wide_table/cases/e08_window_in_filter/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A filter cannot contain a window function", + "question": "(A filter on a row number.)", + "behavior": "The filter is a row predicate.", + "spec": ["3.4", "8"], + "error": "E_WINDOW_IN_WHERE" +} diff --git a/compliance/wide_table/cases/e08_window_in_filter/query.json b/compliance/wide_table/cases/e08_window_in_filter/query.json new file mode 100644 index 000000000..06998c2aa --- /dev/null +++ b/compliance/wide_table/cases/e08_window_in_filter/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["orders.order_id"], + "filter": "ROW_NUMBER() OVER (ORDER BY orders.amount) = 1" +} diff --git a/compliance/wide_table/cases/e09_cross_dataset_filter/expected.json b/compliance/wide_table/cases/e09_cross_dataset_filter/expected.json new file mode 100644 index 000000000..158339c99 --- /dev/null +++ b/compliance/wide_table/cases/e09_cross_dataset_filter/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A filter reads one dataset", + "question": "What is the amount of orders over 100 from customers in EAST?", + "behavior": "The filter reads orders and customers. A Layer 2 query can express it.", + "spec": ["3.4", "7", "8"], + "error": "E_CROSS_DATASET_FILTER" +} diff --git a/compliance/wide_table/cases/e09_cross_dataset_filter/query.json b/compliance/wide_table/cases/e09_cross_dataset_filter/query.json new file mode 100644 index 000000000..8a6677f5a --- /dev/null +++ b/compliance/wide_table/cases/e09_cross_dataset_filter/query.json @@ -0,0 +1,4 @@ +{ + "metrics": ["orders.total_revenue"], + "filter": "orders.amount > 100 AND customers.region = 'EAST'" +} diff --git a/compliance/wide_table/cases/e10_name_collision/expected.json b/compliance/wide_table/cases/e10_name_collision/expected.json new file mode 100644 index 000000000..981abefc0 --- /dev/null +++ b/compliance/wide_table/cases/e10_name_collision/expected.json @@ -0,0 +1,7 @@ +{ + "title": "Output names must be unique", + "question": "(Two columns named region.)", + "behavior": "The alias of the second dimension equals the output name of the first.", + "spec": ["3.3", "8"], + "error": "E_NAME_COLLISION" +} diff --git a/compliance/wide_table/cases/e10_name_collision/query.json b/compliance/wide_table/cases/e10_name_collision/query.json new file mode 100644 index 000000000..599dc54c3 --- /dev/null +++ b/compliance/wide_table/cases/e10_name_collision/query.json @@ -0,0 +1,3 @@ +{ + "dimensions": ["customers.region", {"field": "customers.customer_id", "alias": "region"}] +} diff --git a/compliance/wide_table/cases/e11_unaggregated_field_in_metric/expected.json b/compliance/wide_table/cases/e11_unaggregated_field_in_metric/expected.json new file mode 100644 index 000000000..1848daa40 --- /dev/null +++ b/compliance/wide_table/cases/e11_unaggregated_field_in_metric/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A model-scoped metric with a field outside every aggregate", + "question": "What is amount_less_order?", + "behavior": "orders.amount is outside SUM.", + "spec": ["5.2", "8"], + "error": "E_UNAGGREGATED_FINER_GRAIN_REFERENCE" +} diff --git a/compliance/wide_table/cases/e11_unaggregated_field_in_metric/query.json b/compliance/wide_table/cases/e11_unaggregated_field_in_metric/query.json new file mode 100644 index 000000000..5286424a7 --- /dev/null +++ b/compliance/wide_table/cases/e11_unaggregated_field_in_metric/query.json @@ -0,0 +1,3 @@ +{ + "metrics": ["amount_less_order"] +} diff --git a/compliance/wide_table/cases/e12_windowed_metric/expected.json b/compliance/wide_table/cases/e12_windowed_metric/expected.json new file mode 100644 index 000000000..95e99e6c9 --- /dev/null +++ b/compliance/wide_table/cases/e12_windowed_metric/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A model-scoped metric with a window function is deferred", + "question": "What is running_revenue?", + "behavior": "The metric uses OVER.", + "spec": ["5.2", "8"], + "error": "E_DEFERRED_WINDOWED_METRIC" +} diff --git a/compliance/wide_table/cases/e12_windowed_metric/query.json b/compliance/wide_table/cases/e12_windowed_metric/query.json new file mode 100644 index 000000000..8f3231fb0 --- /dev/null +++ b/compliance/wide_table/cases/e12_windowed_metric/query.json @@ -0,0 +1,3 @@ +{ + "metrics": ["running_revenue"] +} diff --git a/compliance/wide_table/cases/e13_measure_grain_two_datasets/expected.json b/compliance/wide_table/cases/e13_measure_grain_two_datasets/expected.json new file mode 100644 index 000000000..0a7d7c749 --- /dev/null +++ b/compliance/wide_table/cases/e13_measure_grain_two_datasets/expected.json @@ -0,0 +1,7 @@ +{ + "title": "An aggregate whose arguments read two datasets is deferred", + "question": "What is order_less_return?", + "behavior": "SUM reads orders.amount and returns.amount.", + "spec": ["5.2", "8"], + "error": "E_AMBIGUOUS_MEASURE_GRAIN" +} diff --git a/compliance/wide_table/cases/e13_measure_grain_two_datasets/query.json b/compliance/wide_table/cases/e13_measure_grain_two_datasets/query.json new file mode 100644 index 000000000..ff64ef704 --- /dev/null +++ b/compliance/wide_table/cases/e13_measure_grain_two_datasets/query.json @@ -0,0 +1,3 @@ +{ + "metrics": ["order_less_return"] +} diff --git a/compliance/wide_table/cases/e14_measure_grain_no_dataset/expected.json b/compliance/wide_table/cases/e14_measure_grain_no_dataset/expected.json new file mode 100644 index 000000000..2b7f68207 --- /dev/null +++ b/compliance/wide_table/cases/e14_measure_grain_no_dataset/expected.json @@ -0,0 +1,7 @@ +{ + "title": "An aggregate whose arguments read no dataset", + "question": "What is row_count?", + "behavior": "COUNT(*) in a model-scoped metric has no home dataset. A dataset-scoped COUNT(*) expresses the count.", + "spec": ["5.2", "8"], + "error": "E_AMBIGUOUS_MEASURE_GRAIN" +} diff --git a/compliance/wide_table/cases/e14_measure_grain_no_dataset/query.json b/compliance/wide_table/cases/e14_measure_grain_no_dataset/query.json new file mode 100644 index 000000000..80ae0eb08 --- /dev/null +++ b/compliance/wide_table/cases/e14_measure_grain_no_dataset/query.json @@ -0,0 +1,3 @@ +{ + "metrics": ["row_count"] +} diff --git a/compliance/wide_table/cases/e15_no_path/expected.json b/compliance/wide_table/cases/e15_no_path/expected.json new file mode 100644 index 000000000..65192a20b --- /dev/null +++ b/compliance/wide_table/cases/e15_no_path/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A dimension no metric reaches", + "question": "How many customers are there per order?", + "behavior": "customers does not reach orders: relationships are many-to-one, from orders to customers. The error names orders.order_id and customers.customer_count.", + "spec": ["4", "5.3", "8"], + "error": "E_NO_PATH" +} diff --git a/compliance/wide_table/cases/e15_no_path/query.json b/compliance/wide_table/cases/e15_no_path/query.json new file mode 100644 index 000000000..557b9afcc --- /dev/null +++ b/compliance/wide_table/cases/e15_no_path/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["orders.order_id"], + "metrics": ["customers.customer_count"] +} diff --git a/compliance/wide_table/cases/e16_partial_dimension_reachability/expected.json b/compliance/wide_table/cases/e16_partial_dimension_reachability/expected.json new file mode 100644 index 000000000..d31c1db19 --- /dev/null +++ b/compliance/wide_table/cases/e16_partial_dimension_reachability/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A dimension some metrics reach", + "question": "What are the order amount and the number of tickets by customer region?", + "behavior": "orders reaches customers; tickets does not. The error names customers.region and tickets.ticket_count.", + "spec": ["5.3", "8", "B.4"], + "error": "E_PARTIAL_DIMENSION_REACHABILITY" +} diff --git a/compliance/wide_table/cases/e16_partial_dimension_reachability/query.json b/compliance/wide_table/cases/e16_partial_dimension_reachability/query.json new file mode 100644 index 000000000..cf4bcb527 --- /dev/null +++ b/compliance/wide_table/cases/e16_partial_dimension_reachability/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue", "tickets.ticket_count"] +} diff --git a/compliance/wide_table/cases/e17_no_anchor/expected.json b/compliance/wide_table/cases/e17_no_anchor/expected.json new file mode 100644 index 000000000..a7ed725d8 --- /dev/null +++ b/compliance/wide_table/cases/e17_no_anchor/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A query without metrics needs an anchor", + "question": "Which pairs of orders and returns are there?", + "behavior": "Neither orders nor returns reaches the other.", + "spec": ["5.6", "8"], + "error": "E_NO_ANCHOR" +} diff --git a/compliance/wide_table/cases/e17_no_anchor/query.json b/compliance/wide_table/cases/e17_no_anchor/query.json new file mode 100644 index 000000000..3c50ebbfa --- /dev/null +++ b/compliance/wide_table/cases/e17_no_anchor/query.json @@ -0,0 +1,3 @@ +{ + "dimensions": ["orders.order_id", "returns.return_id"] +} diff --git a/compliance/wide_table/cases/e18_filter_path_from_metric/expected.json b/compliance/wide_table/cases/e18_filter_path_from_metric/expected.json new file mode 100644 index 000000000..8741494df --- /dev/null +++ b/compliance/wide_table/cases/e18_filter_path_from_metric/expected.json @@ -0,0 +1,7 @@ +{ + "title": "Every metric must reach the dataset of the filter", + "question": "What are the order and return amounts by customer region, for orders over 100?", + "behavior": "returns does not reach orders. The error names the filter and returns.total_returns.", + "spec": ["5.3", "8", "B.5"], + "error": "E_UNSUPPORTED_FILTER_PATH" +} diff --git a/compliance/wide_table/cases/e18_filter_path_from_metric/query.json b/compliance/wide_table/cases/e18_filter_path_from_metric/query.json new file mode 100644 index 000000000..3aa8b8922 --- /dev/null +++ b/compliance/wide_table/cases/e18_filter_path_from_metric/query.json @@ -0,0 +1,5 @@ +{ + "dimensions": ["customers.region"], + "metrics": ["orders.total_revenue", "returns.total_returns"], + "filter": "orders.amount > 100" +} diff --git a/compliance/wide_table/cases/e19_filter_path_from_anchor/expected.json b/compliance/wide_table/cases/e19_filter_path_from_anchor/expected.json new file mode 100644 index 000000000..2c212be2f --- /dev/null +++ b/compliance/wide_table/cases/e19_filter_path_from_anchor/expected.json @@ -0,0 +1,7 @@ +{ + "title": "The anchor must reach the dataset of the filter", + "question": "Which customer regions have orders over 100?", + "behavior": "The anchor is customers, which does not reach orders. The error names the filter and the anchor.", + "spec": ["5.6", "8", "B.5"], + "error": "E_UNSUPPORTED_FILTER_PATH" +} diff --git a/compliance/wide_table/cases/e19_filter_path_from_anchor/query.json b/compliance/wide_table/cases/e19_filter_path_from_anchor/query.json new file mode 100644 index 000000000..93dc70492 --- /dev/null +++ b/compliance/wide_table/cases/e19_filter_path_from_anchor/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.region"], + "filter": "orders.amount > 100" +} diff --git a/compliance/wide_table/cases/e20_order_invalid_before_name/expected.json b/compliance/wide_table/cases/e20_order_invalid_before_name/expected.json new file mode 100644 index 000000000..66cdb6551 --- /dev/null +++ b/compliance/wide_table/cases/e20_order_invalid_before_name/expected.json @@ -0,0 +1,7 @@ +{ + "title": "The first matching row of Section 8 wins", + "question": "(An unknown part and an unknown reference.)", + "behavior": "Both E_INVALID_QUERY (row 1) and E_NAME_NOT_FOUND (row 3) apply. Row 1 comes first.", + "spec": ["8"], + "error": "E_INVALID_QUERY" +} diff --git a/compliance/wide_table/cases/e20_order_invalid_before_name/query.json b/compliance/wide_table/cases/e20_order_invalid_before_name/query.json new file mode 100644 index 000000000..1a2ebd881 --- /dev/null +++ b/compliance/wide_table/cases/e20_order_invalid_before_name/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.no_such_field"], + "limit": 10 +} diff --git a/compliance/wide_table/cases/e21_order_name_before_filter/expected.json b/compliance/wide_table/cases/e21_order_name_before_filter/expected.json new file mode 100644 index 000000000..4861a761d --- /dev/null +++ b/compliance/wide_table/cases/e21_order_name_before_filter/expected.json @@ -0,0 +1,7 @@ +{ + "title": "A reference error comes before a filter error", + "question": "(An unknown reference and a filter over two datasets.)", + "behavior": "Both E_NAME_NOT_FOUND (row 3) and E_CROSS_DATASET_FILTER (row 8) apply. Row 3 comes first.", + "spec": ["8"], + "error": "E_NAME_NOT_FOUND" +} diff --git a/compliance/wide_table/cases/e21_order_name_before_filter/query.json b/compliance/wide_table/cases/e21_order_name_before_filter/query.json new file mode 100644 index 000000000..0fe2c65b2 --- /dev/null +++ b/compliance/wide_table/cases/e21_order_name_before_filter/query.json @@ -0,0 +1,4 @@ +{ + "dimensions": ["customers.no_such_field"], + "filter": "orders.amount > 100 AND customers.region = 'EAST'" +} diff --git a/compliance/wide_table/retail/retail.sql b/compliance/wide_table/retail/retail.sql new file mode 100644 index 000000000..2256022e3 --- /dev/null +++ b/compliance/wide_table/retail/retail.sql @@ -0,0 +1,78 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- ============================================================================ +-- 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. +-- +-- 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 +-- gives no rows for tickets (Appendix B.4), so the table is empty. +-- ============================================================================ + +DROP SCHEMA IF EXISTS retail CASCADE; +CREATE SCHEMA retail; + +CREATE TABLE retail.customers ( + customer_id VARCHAR NOT NULL PRIMARY KEY, + region VARCHAR NOT NULL +); + +INSERT INTO retail.customers VALUES + ('C1', 'EAST'), + ('C2', 'EAST'), + ('C3', 'WEST'), + ('C4', 'NORTH'); + +CREATE TABLE retail.orders ( + order_id VARCHAR NOT NULL PRIMARY KEY, + customer_id VARCHAR NOT NULL, + amount INTEGER NOT NULL +); + +INSERT INTO retail.orders VALUES + ('O1', 'C1', 100), + ('O2', 'C1', 200), + ('O3', 'C2', 50), + ('O4', 'C3', 300); + +CREATE TABLE retail.returns ( + return_id VARCHAR NOT NULL PRIMARY KEY, + customer_id VARCHAR NOT NULL, + amount INTEGER NOT NULL +); + +INSERT INTO retail.returns VALUES + ('R1', 'C1', 25), + ('R2', 'C4', 10); + +CREATE TABLE retail.visits ( + visit_id VARCHAR NOT NULL PRIMARY KEY, + customer_id VARCHAR NOT NULL +); + +INSERT INTO retail.visits VALUES + ('V1', 'C4'), + ('V2', 'C4'), + ('V3', 'C3'); + +CREATE TABLE retail.tickets ( + ticket_id VARCHAR NOT NULL PRIMARY KEY +); diff --git a/compliance/wide_table/retail/retail_model.ossie.yaml b/compliance/wide_table/retail/retail_model.ossie.yaml new file mode 100644 index 000000000..a4b406387 --- /dev/null +++ b/compliance/wide_table/retail/retail_model.ossie.yaml @@ -0,0 +1,184 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# 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). +# +# 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 +# its numerator to DOUBLE: the SQL standard leaves the scale of a division of +# two exact numerics implementation-defined (../../query/README.md, "Result +# semantics"). +# +# The other model-scoped metrics are rejected when a query names them (Section +# 5.2). They exist for the error cases. + +version: 0.3.0.dev0 +name: retail +description: Customers with orders, returns, and visits, and unrelated tickets +datasets: + - name: customers + source: retail.customers + primary_key: [customer_id] + fields: + - name: customer_id + datatype: String + expression: + sql: customer_id + - name: region + datatype: String + expression: + sql: region + metrics: + - name: customer_count + description: Number of customers + datatype: Integer + expression: + sql: COUNT(*) + + - name: orders + source: retail.orders + primary_key: [order_id] + fields: + - name: order_id + datatype: String + expression: + sql: order_id + - name: customer_id + datatype: String + expression: + sql: customer_id + - name: amount + datatype: Integer + expression: + sql: amount + metrics: + - name: total_revenue + description: Total order amount + datatype: Integer + expression: + sql: SUM(amount) + + - name: returns + source: retail.returns + primary_key: [return_id] + fields: + - name: return_id + datatype: String + expression: + sql: return_id + - name: customer_id + datatype: String + expression: + sql: customer_id + - name: amount + datatype: Integer + expression: + sql: amount + metrics: + - name: total_returns + description: Total return amount + datatype: Integer + expression: + sql: SUM(amount) + - name: return_count + description: Number of returns + datatype: Integer + expression: + sql: COUNT(*) + + - name: visits + source: retail.visits + primary_key: [visit_id] + fields: + - name: visit_id + datatype: String + expression: + sql: visit_id + - name: customer_id + datatype: String + expression: + sql: customer_id + metrics: + - name: visit_count + description: Number of visits + datatype: Integer + expression: + sql: COUNT(*) + + - name: tickets + source: retail.tickets + primary_key: [ticket_id] + fields: + - name: ticket_id + datatype: String + expression: + sql: ticket_id + metrics: + - name: ticket_count + description: Number of tickets + datatype: Integer + expression: + sql: COUNT(*) + +relationships: + - name: orders_to_customers + from: orders + to: customers + from_columns: [customer_id] + to_columns: [customer_id] + - name: returns_to_customers + from: returns + to: customers + from_columns: [customer_id] + to_columns: [customer_id] + - name: visits_to_customers + from: visits + to: customers + from_columns: [customer_id] + to_columns: [customer_id] + +metrics: + - name: revenue_per_customer + description: Order amount per customer, counting customers without orders + datatype: Float + expression: + sql: CAST(SUM(orders.amount) AS DOUBLE) / COUNT(DISTINCT customers.customer_id) + - name: amount_less_order + description: Rejected, a field outside every aggregate + datatype: Integer + expression: + sql: SUM(orders.amount) - orders.amount + - name: running_revenue + description: Rejected, a window function + datatype: Integer + expression: + sql: SUM(orders.amount) OVER () + - name: order_less_return + description: Rejected, an aggregate whose arguments read two datasets + datatype: Integer + expression: + sql: SUM(orders.amount - returns.amount) + - name: row_count + description: Rejected, an aggregate whose arguments read no dataset + datatype: Integer + expression: + sql: COUNT(*) From de21ed2bddc4943f7672fbef6e078d4f1c9424f7 Mon Sep 17 00:00:00 2001 From: Alex Kosachev Date: Fri, 13 Nov 2026 14:03:22 +0800 Subject: [PATCH 2/2] fix(compliance): let e12 match only row 11, validate the retail model 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. --- Makefile | 2 +- compliance/wide_table/retail/retail_model.ossie.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 912d5d930..195286703 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,7 @@ compliance-test: check-dependencies ## Run portability grader tests compliance-validate: DEPENDENCIES := $(UV) compliance-validate: check-dependencies ## Validate compliance models and portability fixtures @echo "--- Validating compliance fixtures ---" - @$(UV) run --no-project validation/validate.py compliance/portability/m*/*.ossie.yaml compliance/query/scott/scott_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/retail/retail_model.ossie.yaml @echo "--- Compliance fixture validation complete ---" .PHONY: compliance-query diff --git a/compliance/wide_table/retail/retail_model.ossie.yaml b/compliance/wide_table/retail/retail_model.ossie.yaml index a4b406387..fc48337ea 100644 --- a/compliance/wide_table/retail/retail_model.ossie.yaml +++ b/compliance/wide_table/retail/retail_model.ossie.yaml @@ -171,7 +171,7 @@ metrics: description: Rejected, a window function datatype: Integer expression: - sql: SUM(orders.amount) OVER () + sql: SUM(SUM(orders.amount)) OVER () - name: order_less_return description: Rejected, an aggregate whose arguments read two datasets datatype: Integer