Skip to content

feat(core-spec): name a dataset-scoped metric's column by its reference (breaking) - #778

Open
ZmeiGorynych wants to merge 3 commits into
apache:mainfrom
MotleyAI:dataset-metric-output-names
Open

ZmeiGorynych wants to merge 3 commits into
apache:mainfrom
MotleyAI:dataset-metric-output-names

Conversation

@ZmeiGorynych

@ZmeiGorynych ZmeiGorynych commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

In Layer 3 (core-spec/wide_table_semantics.md), an unaliased dataset-scoped metric's output name becomes its reference, dataset.metric, instead of the metric name alone:

{"dimensions": ["customers.region"], "metrics": ["orders.total_revenue", "returns.total_returns"]}
region | orders.total_revenue | returns.total_returns

Fields keep the final part of their reference (customers.region → region), and model-scoped metrics keep their name. Uniqueness (E_NAME_COLLISION) compares output names part by part under identifier normalization. A binding that labels columns with identifiers writes a two-part name as one delimited identifier, such as "orders.total_revenue" in SQL.

Breaking within unreleased 0.3.0.dev0. Unaliased dataset-scoped metric columns get new labels. Query semantics, rows and values don't change.

Rationale

1. The final-part rule for metrics comes from the time when every metric was model-scoped. #246 (Foundational Semantics) left dataset.field result names to engines, and said metrics "do not have this ambiguity (the result column is the metric's name...)". That was true then: "Every metric lives in one global namespace" (#246 §4.6), and dataset-scoped metrics were deferred. #591 added dataset-scoped metrics, whose names are unique only within their dataset (Metric Scoping, rule 4). #653 then applied the final-part rule to metrics and fields alike. As far as I can find, no reasoning was recorded for metrics: it isn't in #653's review or in its [DISCUSS] thread on dev@.

2. The final part drops what makes a dataset-scoped metric unique. Its reference, dataset.metric, is its only unique name; the metric name alone is not. A column labelled total_amount can't be traced back to its metric without the query, while orders.total_amount can.

3. The current rule makes a modelling pattern the spec allows collide. Metric names are unique only within each dataset, so two datasets can both declare total_amount, row_count, item_count and so on. #343's proposal said so outright ("two datasets MAY each declare item_count"). §3.3 uses this exact pattern as its collision example: orders.total_amount and returns.total_amount must be aliased. Every query across two fact datasets with conventionally named metrics hits E_NAME_COLLISION, which matters most for agents generating queries.

4. Model-scoped and dataset-scoped metrics may share a name. Nothing in Metric Scoping or the validator forbids a model-scoped total_revenue next to orders.total_revenue. Their references differ, but under the final-part rule their columns collide.

5. It matches how metrics are referenced elsewhere. Consumers query a dataset-scoped metric as dataset.metric, and model-scoped metrics evaluate it as AGG(dataset.metric). The label is now the same string.

Fields are deliberately unchanged. #246 noted that engines name dataset.field result columns differently, and the leaf name is the common SQL convention. Dimensions such as region are usually conformed attributes, where the leaf is the natural label. Fields can collide too (customers.region and stores.region), but changing them is a larger, separate question. This PR only changes the case where the original premise of the rule no longer holds.

Prior art

These are the semantic layers I checked in which two datasets can declare metrics of the same name and both can appear in one query. Almost all of them keep the two result columns apart by qualifying them:

  • Always qualified: Cube's REST API (orders.count), Looker's JSON results (orders.count), Omni (orders.count), Lightdash (orders_count) and Honeydew (orders.count).
  • Qualified on collision: Malloy renames a colliding joined reference such as orders.total to orders_total, with a warning. This arrived in June 2026; before that, the collision was an error. Boring Semantic Layer requires the qualified spelling when short names collide, and keeps that spelling in the output.
  • Not qualified: Snowflake semantic views require table.name in the reference when names collide, but name output columns with "the unqualified names of the metrics and dimensions". Its documented example, two dimensions both called name, returns two columns labelled NAME, and the consumer has to alias them. Only SHOW COLUMNS lists ambiguous names qualified.

Systems whose metric names are unique across the whole model, such as dbt MetricFlow, AtScale SML and Power BI, label metrics by their bare name, as #246 did. They have no collision to resolve.

Qualifying only on collision makes a column's name depend on the other entries in the query: adding returns.total_amount would rename the column of orders.total_amount. Layer 3 can't leave duplicate labels either, because output names MUST be unique. Always qualifying dataset-scoped metrics avoids both problems.

Survey of 17 semantic layers: how metric result columns are labelled (sources per row)

Checked on 2026-11-20 against official docs, API references and source code. "Unverified" means no such source settled the point. A dataset name that is part of the metric's own name (Snowflake's CUSTOMER_ORDER_COUNT) does not count as a prefix.

Dataset-scoped metrics, same names allowed

System Where metrics live Same name in two datasets? Result column label Prefix Sources
Snowflake semantic views Per logical table; derived metrics at view level Yes; dot notation required when names collide SQL: unqualified (CUSTOMER_ORDER_COUNT), AS alias. Documented same-named dimensions: two NAME columns, docs say to alias. No same-named metric pair shown. SHOW COLUMNS lists ambiguous names as orders.revenue Absent querying, SEMANTIC_VIEW, CREATE
Malloy Measures in sources Yes; unique per source Last path segment (carrier_count); name is … renames. Colliding dotted reference auto-renamed to carriers_carrier_count with a warning (since 2026-06; error before) Absent; on collision only join docs, field-references.ts
Cube Measures in cubes Yes; unique per cube REST: users.count, no alias. SQL API: bare count or AS alias. Views: users_city with prefix: true REST mandated; SQL absent REST, SQL API, views
Looker (LookML) Measures in views Yes; view-scoped API json: dashboard.count. csv / json_label: "Dashboard Count" (renamable label). SQL interface: metadata orders.amount, result columns unverified json mandated; labels optional SQL interface, SDK test
Omni Measures in views Yes; unique per view API JSON / CSV: inventory_items.count; no rename option found. UI export unverified Mandated measures, run query
Lightdash Metrics in dbt model YAML Yes; field IDs include the table JSON and SQL alias: orders_count. CSV / XLSX: label, table name only with showTableNames; customLabels overrides JSON mandated; downloads optional metrics, item.ts, CsvService.ts
Honeydew Metrics on entities Yes, by example Dynamic datasets / native app: lineitems.daily_revenue_contribution (example output). SQL interface unverified Mandated (by example) metrics, native app
Boring Semantic Layer Measures per semantic table Yes; tests join two tables with count Exactly the requested string; keyword aliases. Short name errors on collision, so both come back qualified Optional; mandated on collision fieldref.py, join test
Holistics Measures in models; metrics in datasets Unverified Query API: display labels ("GMV (Gross Merchandise Value)"); AQL custom names Absent query API, AQL

Scoped per view, one view per query (same-named metrics never meet)

System Where metrics live Same name in two datasets? Result column label Prefix Sources
Databricks metric views Top-level measures of one metric view Not within a view Docs always alias to the bare name; un-aliased header unverified Absent syntax, MEASURE
Rill Measures in a metrics view over one model Across views presumably; unverified Bare (AS total_records); AS allowed Absent metrics views, metrics SQL
Wren AI Calculated columns in models; cube measures Cubes unverified Bare (SUM(amount) AS revenue) Absent cubes, cube.rs
ThoughtSpot Model columns and formulas No; unique per data source "Total Sales" (aggregation + name) Absent TML models, search API

Metric names unique across the model (no collision to resolve)

System Where metrics live Same name in two datasets? Result column label Prefix Sources
dbt MetricFlow Simple metrics in semantic models, others top-level No; unique project-wide CLI / JDBC: ORDER_TOTAL; alias= Absent metrics, JDBC
AtScale SML Standalone metrics pointing at a dataset No; unique across repositories SQL / JDBC: unique_name or per-model query_name Absent metric.md, JDBC
Power BI / Tabular Model-level measures; home table cosmetic No; unique in the model DAX: caller's name [Sales]; REST executeQueries: [MyNewColumn] Absent measure refs, executeQueries
GoodData Facts in datasets; metrics workspace-level No; IDs unique per type Execution API: caller's localIdentifier plus metric title Absent raw data API, MAQL

Alternatives considered

  • Allow either label (SHOULD or MAY). E_NAME_COLLISION is a MUST, so output names have to be deterministic. If some engines prefix and others don't, the same query either collides or runs depending on the engine. That defeats the point of a shared Layer 3.
  • Join with an underscore (orders_total_revenue). No quoting needed, but the label can clash with real names (orders_total + revenue vs orders + total_revenue), and it no longer equals the reference.
  • Keep the final part. The status quo, with the collisions in points 3 and 4.

Changes

  • core-spec/wide_table_semantics.md: the §3.3 output-name table, the uniqueness rule and the delimited-label guidance; the §1.3 example, the §5.5 plan and the Appendix B.2 result table.
  • compliance/wide_table/: the expected headers and query.ossie.sql output aliases of the 17 cases with unaliased dataset-scoped metrics (a01–a06, a10, a11, a13–a21). The README example table is updated too. Rows and values are unchanged.
  • New compliance case a22_same_metric_name: the retail fixture gains orders.total_amount and returns.total_amount, both SUM(amount). Querying both by region returns the columns orders.total_amount and returns.total_amount instead of raising E_NAME_COLLISION. The new metrics don't affect any other case, and the fixtures pass make compliance-validate.
  • docs/spec_changes.md: an entry with rationale and impact. Its date is a placeholder, to fill in at merge.

Related Issues

Relates to #653 (Layer 3), #591 (dataset-scoped metrics), #246 (Foundational Semantics).

Checklist

Specification

  • Spec changes are included in core-spec/ and follow the existing structure
  • Spec changes have a [DISCUSS] thread on dev@ with a stated end date, and reach lazy consensus (or pass a [VOTE]) before merge — thread:
  • Breaking changes to the spec are clearly called out in the summary
  • For a material spec change, docs/spec_changes.md records rationale, compatibility and migration impact

Ontology

  • Ontology changes in ontology/ are consistent with spec changes (none needed)
  • New or modified terms are defined and documented

Converters

  • Spec or ontology changes that affect converters have a matching issue or PR in apache/ossie-converters (none affected: converters don't produce Layer 3 results)

Validation

  • Validation rules in validation/ are updated if the spec changed (no Layer 3 query validation exists)
  • New validation cases are covered by tests (n/a)

Documentation

  • docs/ is updated to reflect any user-facing changes
  • New features or behaviors are documented with examples where appropriate
  • CONTRIBUTING.md is updated if the contribution process changed (n/a)

Examples

  • examples/ are added or updated for any new spec constructs (n/a)

Tests

  • All existing tests pass (pytest / CI green)
  • New functionality is covered by tests (compliance cases updated)

Compliance

  • ASF license headers are present on all new source files (no new files)
  • New third-party dependencies follow Third-Party Dependencies (none)
  • If third-party source code is vendored/copied, NOTICE and/or LICENSE have been updated (n/a)

AI disclosure

Per the ASF Generative Tooling Guidance, this contribution was prepared with AI assistance. I have reviewed and verified every change.

…ce (breaking)

In Layer 3, the output name of an unaliased dataset-scoped metric is its
reference, `dataset.metric`, instead of the metric name alone. Fields and
model-scoped metrics keep their output names. Two output names are equal
when they have the same parts under identifier normalization.

The worked examples, the Section 5.5 plan, Appendix B.2 and the wide-table
compliance cases are updated; docs/spec_changes.md records the change.
orders and returns both declare total_amount; the query runs, with the
columns orders.total_amount and returns.total_amount.
@github-actions

Copy link
Copy Markdown

Thank you for your first contribution to Apache Ossie (incubating)!

A committer will review your PR. In the meantime, please ensure:

  • All CI checks pass
  • ASF license headers are present on new source files
  • Tests cover new functionality

No ICLA is required to contribute. If you are elected as a committer in the future, you will need an Individual Contributor License Agreement (ICLA) on file with the ASF.

Questions? Ask in the PR comments or join us on Slack.

We appreciate your contribution!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant