Repository navigation
fix(core-spec, ontology): reject a list that names the same thing twice #705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,8 +168,8 @@ Logical datasets represent business entities or concepts (fact and dimension tab | |
| |-------|------|----------|-------------| | ||
| | `name` | string | Yes | Unique identifier for the dataset | | ||
| | `source` | string | Yes | Reference to underlying physical table/view (e.g., `database.schema.table`) or query | | ||
| | `primary_key` | array | No | Dataset fields that uniquely identify rows | | ||
| | `unique_keys` | array of arrays | No | Array of unique key definitions, each a list of dataset fields | | ||
| | `primary_key` | array | No | Dataset fields that uniquely identify rows, each named once | | ||
| | `unique_keys` | array of arrays | No | Array of unique key definitions, each a list of dataset fields naming each field once | | ||
| | `description` | string | No | Human-readable description | | ||
| | `ai_context` | string/object | No | Additional context for AI tools (e.g., synonyms, common terms) | | ||
| | `fields` | array | No | Row-level attributes for grouping, filtering, and metric expressions | | ||
|
|
@@ -195,6 +195,14 @@ unique_keys: | |
| - [first_name, last_name] # Composite unique key | ||
| ``` | ||
|
|
||
| A key is the set of fields it names, so it names each of them once. Unquoted | ||
| field names resolve case-insensitively (see | ||
| [Namespacing and Identifier Resolution](expression_language.md#namespacing-and-identifier-resolution)), | ||
| so `[email, EMAIL]` names one field twice and is invalid. Two `unique_keys` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes 🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it. |
||
| definitions that name the same fields, in any order and in any case, declare one | ||
| key twice; that is redundant rather than invalid, and validation reports it as a | ||
| warning. | ||
|
|
||
| ### Example | ||
|
|
||
| ```yaml | ||
|
|
@@ -877,6 +885,7 @@ including rationale and migration impact for consumers, see the | |
| - Breaking: metric expressions, `primary_key`, `unique_keys`, and relationship `from_columns`/`to_columns` refer to dataset fields, not columns of the dataset's `source`. Model-scoped metric expressions must use qualified `dataset.field` references; dataset-scoped metric expressions use unqualified field names. Earlier versions did not specify this, and some converters read these names as source columns; those converters must now resolve them as fields. See [Name Resolution](#name-resolution). | ||
| - Dataset-scoped metric expressions may reference columns of the dataset's `source`, written as `source.column`. See [Metric Scoping](#metric-scoping). | ||
| - Model-scoped metric expressions may evaluate a dataset-scoped metric with `AGG(dataset.metric)`. See [Metric Scoping](#metric-scoping). | ||
| - Breaking: a key names each field once. `primary_key` and each `unique_keys` definition may no longer repeat a field, and because field names resolve case-insensitively, `[email, EMAIL]` repeats one. Documents that named a field twice declared fewer columns than they appeared to and now fail validation. A `unique_keys` definition that restates another remains valid and is reported as a warning. See [Datasets](#datasets). | ||
| - **0.1.1** (2025-12-11): Initial release | ||
| - Core semantic model structure | ||
| - Support for datasets, relationships, fields, and metrics | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| "items": { | ||
| "$ref": "#/$defs/Expression" | ||
| }, | ||
| "uniqueItems": true, | ||
| "description": "Expressions that constrain the population of this ontology" | ||
| }, | ||
| "ontology": { | ||
|
|
@@ -80,13 +81,15 @@ | |
| "type": "string", | ||
| "minLength": 1 | ||
| }, | ||
| "uniqueItems": true, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for the ontology. Since #673, Could we add that to those rows (e.g. "each must be non-empty and listed once") and add a Version History entry? Otherwise we bring back the schema/spec drift that #673 just fixed. |
||
| "description": "Indicates that this concept extends one or more other concepts" | ||
| }, | ||
| "derived_by": { | ||
| "type": "array", | ||
| "items": { | ||
| "$ref": "#/$defs/Expression" | ||
| }, | ||
| "uniqueItems": true, | ||
| "description": "Expressions that define how this concept is derived" | ||
| }, | ||
| "identify_by": { | ||
|
|
@@ -95,13 +98,15 @@ | |
| "type": "string", | ||
| "minLength": 1 | ||
| }, | ||
| "uniqueItems": true, | ||
| "description": "Names of relationships to use as the preferred identifier of this concept" | ||
| }, | ||
| "requires": { | ||
| "type": "array", | ||
| "items": { | ||
| "$ref": "#/$defs/Expression" | ||
| }, | ||
| "uniqueItems": true, | ||
| "description": "Expressions that constrain the population of this concept" | ||
| }, | ||
| "relationships": { | ||
|
|
@@ -153,13 +158,15 @@ | |
| "items": { | ||
| "$ref": "#/$defs/Expression" | ||
| }, | ||
| "uniqueItems": true, | ||
| "description": "Expressions that define how this concept is derived" | ||
| }, | ||
| "requires": { | ||
| "type": "array", | ||
| "items": { | ||
| "$ref": "#/$defs/Expression" | ||
| }, | ||
| "uniqueItems": true, | ||
| "description": "Expressions that constrain the population of this relationship" | ||
| }, | ||
| "verbalizes": { | ||
|
|
@@ -168,6 +175,7 @@ | |
| "type": "string", | ||
| "minLength": 1 | ||
| }, | ||
| "uniqueItems": true, | ||
| "description": "Natural language expressions that verbalize this relationship" | ||
| }, | ||
| "iri": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,11 +88,16 @@ A field described below as non-empty cannot be the empty string `""`. This appli | |
| string that names or references something, to IRIs, and to expressions. Descriptions are free | ||
| text and may be empty. | ||
|
|
||
| A list whose entries are described below as listed once cannot repeat one. A supertype, an | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: 'described below as listed once cannot repeat one' took me two reads. Maybe 'A list marked listed once must not repeat an entry.'? 🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it. |
||
| identifying relationship, a constraint or a verbalization pattern given twice says nothing | ||
| the first one does not already say. | ||
|
|
||
| | Field | Type | Required | Description | | ||
| |-------|------|----------|-------------| | ||
| | `name` | string | Yes | Unique name of this specification; must be non-empty | | ||
| | `description` | string | No | Human-readable description | | ||
| | `ai_context` | string/object | No | Additional context for AI tools | | ||
| | `requires` | list | No | Expressions that constrain the population of this ontology; each must be non-empty and listed once | | ||
| | `ontology` | list | Yes | Concepts and relationships they group that form this ontology | | ||
| | `prefixes` | object | No | Namespace prefixes used to abbreviate [IRIs](#global-identifiers); each prefix's IRI must be non-empty | | ||
| | `ontology_mappings` | list | No | Deprecated; accepted only so existing documents continue to validate. Write mappings as [mapping documents](#mapping-documents) instead | | ||
|
|
@@ -114,10 +119,10 @@ Concepts have the following schema: | |
| | `concept` | string | Yes | Unique name of this concept; must be non-empty | | ||
| | `type` | ConceptType | Yes | Entity type or value type | | ||
| | `description` | string | No | Human-readable description | | ||
| | `extends` | list | No | Names of this concept's supertypes; each must be non-empty | | ||
| | `derived_by` | list | No | Expressions that derive this concept's population; each must be non-empty | | ||
| | `identify_by` | list | No | Names of relationships that uniquely reference objects of this concept; each must be non-empty | | ||
| | `requires` | list | No | Expressions that constrain this concept's population; each must be non-empty | | ||
| | `extends` | list | No | Names of this concept's supertypes; each must be non-empty and listed once | | ||
| | `derived_by` | list | No | Expressions that derive this concept's population; each must be non-empty and listed once | | ||
| | `identify_by` | list | No | Names of relationships that uniquely reference objects of this concept; each must be non-empty and listed once | | ||
| | `requires` | list | No | Expressions that constrain this concept's population; each must be non-empty and listed once | | ||
| | `relationships` | list | No | Relationships where this concept plays the first role | | ||
| | `iri` | string | No | Optional [global identifier](#global-identifiers) of this concept; must be non-empty when present | | ||
|
|
||
|
|
@@ -161,9 +166,9 @@ Each relationship that is declared under a concept conforms to the following sch | |
| | `description` | string | No | Human-readable description | | ||
| | `multiplicity` | enum | No | Multiplicity constraint | | ||
| | `roles` | list | No | List of additional roles in this relationship | | ||
| | `derived_by` | list | No | Expressions that derive links of this relationship; each must be non-empty | | ||
| | `requires` | list | No | Expressions that constrain this relationship's population; each must be non-empty | | ||
| | `verbalizes` | list | Yes | Patterns describing how to verbalize links; each must be non-empty | | ||
| | `derived_by` | list | No | Expressions that derive links of this relationship; each must be non-empty and listed once | | ||
| | `requires` | list | No | Expressions that constrain this relationship's population; each must be non-empty and listed once | | ||
| | `verbalizes` | list | Yes | Patterns describing how to verbalize links; each must be non-empty and listed once | | ||
| | `iri` | string | No | Optional [global identifier](#global-identifiers) of this relationship; must be non-empty when present | | ||
|
|
||
| Each relationship is uniquely identified by prepending its declared name with that of the containing | ||
|
|
@@ -699,6 +704,8 @@ though `Store` plays a role in three of the relationships. | |
| - **0.3.0.dev0** (Unreleased; started as 0.2.0.dev0 on 2026-05-29): Basic support for ontologies and logical schema mappings | ||
| - Breaking: each ontology map's `semantic_model` now requires its own `version`. | ||
| - Breaking: names, IRIs, prefix IRIs and expressions can no longer be empty strings. | ||
| - Breaking: `extends`, `identify_by`, `verbalizes`, and `requires` and `derived_by` wherever | ||
| they appear, list each entry once; a repeated name or expression is no longer accepted. | ||
| - Core ontology structure: Concepts, relationships, and business rules (requires and derived_by) | ||
| - Schema mappings from one or more logical models into an ontology | ||
| - Optional IRIs on concepts and relationships, with namespace prefixes declared at the top level | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new constraints should also go into
core-spec/spec.md. The dataset table rows forprimary_keyandunique_keysdon't say a field can't be named twice, and Version History has no entry. Documents that passed before this PR now fail, so the spec should say why.For example, "Dataset fields that uniquely identify rows, each named once" for
primary_key, the same rule for eachunique_keysdefinition, and a Version History line for the change.