From 48f9538c869e5c09845874df1533c88d4a3091ef Mon Sep 17 00:00:00 2001 From: acrylJonny Date: Fri, 4 Dec 2026 11:50:21 +0000 Subject: [PATCH] docs(ingest/odcs): restructure the ODCS source docs for scanning Co-Authored-By: Claude Opus 5.5 --- .../docs/sources/odcs/README.md | 110 +-- .../docs/sources/odcs/odcs_post.md | 906 +++++++++--------- .../docs/sources/odcs/odcs_pre.md | 206 ++-- .../docs/sources/odcs/odcs_recipe.yml | 22 +- 4 files changed, 596 insertions(+), 648 deletions(-) diff --git a/metadata-ingestion/docs/sources/odcs/README.md b/metadata-ingestion/docs/sources/odcs/README.md index 8c80128056040..a8443fbc9d043 100644 --- a/metadata-ingestion/docs/sources/odcs/README.md +++ b/metadata-ingestion/docs/sources/odcs/README.md @@ -1,76 +1,54 @@ ## Overview -The Open Data Contract Standard (ODCS) is the Linux Foundation / Bitol open YAML -standard for data contracts. It defines a vendor-neutral schema covering a contract's -fundamentals, schema, data quality rules, servers, ownership, tags, SLA, support, and -custom properties. Learn more at the audience-friendly [Bitol home page](https://bitol.io/) -and the canonical [open-data-contract-standard repository](https://github.com/bitol-io/open-data-contract-standard) -(spec text and JSON Schemas). - -ODCS v3 describes a **producer-published dataset specification** — what a dataset _should_ -look like — rather than a bilateral agreement between a specific producer and consumer. -The DataHub `odcs` source therefore models each contract as a **logical dataset** on the -`odcs` platform (a Logical Model); a native `dataContract` entity referencing its assertions is -emitted alongside it by default. A single ODCS file may -describe multiple tables: each `schema[]` entry becomes its own logical `odcs` Dataset -carrying dataset properties, canonical schema metadata, ownership, tags, a link to the -source document, one Assertion per `quality[]` rule, and one schema-compliance assertion — -all attached to the **logical** dataset. When a `schema[]` entry resolves to a physical -dataset (derived from the contract's typed `servers[]`), the source also links the -physical dataset to the logical one with `logicalParent` (the `PhysicalInstanceOf` -relationship). Propagation of the contract's expectations onto physical instances is -handled by DataHub through that relationship. With `bind_to_physical_dataset`, the -assertions and contract go on the bound physical table instead, and a one-server contract -gets no logical dataset. - -These ODCS datasets live on a data platform explicitly marked as logical. +The [Open Data Contract Standard](https://bitol.io/) (ODCS) is a vendor-neutral YAML standard +for data contracts, maintained by the Linux Foundation's Bitol project. A contract describes +what a dataset should look like: its schema, quality rules, servers, owners, tags, SLAs and +support channels. The spec text and JSON Schemas live in the +[open-data-contract-standard repository](https://github.com/bitol-io/open-data-contract-standard). + +The `odcs` source reads ODCS v3.0, v3.1 and v3.2 files and turns each `schema[]` entry +into a dataset with its schema, description, owners, tags, links and glossary terms, plus +one assertion per quality rule, a schema-compliance assertion and a native data contract. +By default these go on a **logical** dataset on the `odcs` platform, linked to the physical +table with `logicalParent`; with `bind_to_physical_dataset` they go on the physical table +itself. Domains, data product output ports and stale-metadata removal are optional. :::info Logical Models are in private beta -Logical Models render in the DataHub UI only when the `LOGICAL_MODELS_ENABLED` feature flag -is on (off by default). The logical `odcs` datasets — and the assertions attached to them — -are ingested either way, but are not displayed until the flag is enabled. See -[Limitations](#limitations) on the module page for the recommended workflow. +The logical `odcs` datasets, and the assertions on them, are always ingested but only show +in the UI when the `LOGICAL_MODELS_ENABLED` feature flag is on (off by default). The `odcs` +platform is marked as logical. ::: ## Concept Mapping -The table below lists the ODCS fields this source maps. Fields not in the table are not mapped; -see [Limitations](#limitations) on the module page for which of them are reported and which are -not. ODCS v3.2 support is partial: v3.2 contracts are accepted and validated, and only the v3.2 -additions listed here are mapped. - -| Source Concept | DataHub Concept | Notes | -| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `id` + `schema[].name` | Logical `odcs` Dataset URN | One logical dataset per `schema[]` entry. URN name defaults to `{contract_id}.{schema_name}` (configurable via `logical_dataset_name_template`). | -| `name` + `schema[].name` | `datasetProperties.name` | Display name `" — "` when both are present. | -| `id`, `version`, `apiVersion`, `status`, `domain`, … | `datasetProperties.customProperties` (`odcs.*`) | Provenance keys: `odcs.id`, `odcs.version`, `odcs.apiVersion`, `odcs.status`, `odcs.schemaName`, `odcs.physicalName`, `odcs.sourceFile`, `odcs.qualityRuleCount`. | -| `schema[].description`, `dataGranularityDescription`, contract `description` | `datasetProperties.description` | Joined in that order: the table description, `**Grain:**`, then the contract's `purpose` / `usage` / `limitations`. | -| `schema[].properties[]` (`name`, `logicalType`, `physicalType`) | `schemaMetadata.fields[]` | Canonical schema on the logical dataset. Types map to a `SchemaFieldDataType`; unmapped types fall back to `NullType` and are reported. | -| Property `required` / `primaryKey` | `schemaField.nullable` / `isPartOfKey` | `nullable = not required`. Nested `properties[]` use dotted field paths (`address.city`). | -| Property `description` / `tags[]` | `schemaField.description` / `globalTags` | `tag_prefix` is prepended to tags if configured. | -| v3.2 `context` (contract, schema object) | `datasetProperties.description` | Appended as a `**Guidance for AI and analysts:**` section: instructions, `**Constraints:**`, `**Verified Q&A:**`. | -| v3.2 property `enum` | `schemaField.description` | Appended as an `**Allowed values:**` list with each value's `label` and `description`. | -| Property `transformDescription` / `transformLogic` | `schemaField.description` | Appended as a `**Derivation:**` section, the logic in a SQL code block. | -| Top-level `tags[]` | `globalTags` on the logical dataset | Emitted when `replicate_contract_metadata=true` (default). | -| `team[]` entries (`role`, `username`) | `ownership` on the logical dataset | `role` maps to an OwnershipType; roles the source does not know default to Technical Owner and are reported as an info. Members with `dateOut` are skipped. Emitted when `replicate_contract_metadata=true`. | -| `authoritativeDefinitions[]` (root, schema, and property level) | `institutionalMemory` | Author-provided URLs linked from the logical dataset. | -| Property `authoritativeDefinitions[]` with `type: businessDefinition` | `schemaField.glossaryTerms` | The `url` is a term reference (`term:order_line`, a plain name, or a `urn:li:glossaryTerm:` URN) resolved as described in [Glossary terms](#glossary-terms); a reference with characters other than letters, digits, whitespace, `_`, `-`, `.` and `:` is reported as skipped. A web URL stays a link; a path (anything containing `/`) is reported as a skipped link. | -| Property `classification` | `schemaField.glossaryTerms` | The term `classification:`, resolved the same way (`confidential` → `classification-confidential`, `機密` → `classification-機密`), or the term `classification_glossary_term_mapping` maps the value to. | -| Property `businessName` | `schemaField.description` | Appended as a `**Business name:**` section, unless it only re-cases the column name (`OrderId` for `order_id`). | -| `slaProperties[]` entry with `property: latency` | `FreshnessAssertionInfo` (fixed interval) on the logical dataset, referenced as the `dataContract`'s freshness | Needs a whole positive `value` and a `unit` of `min`, `h`, `d`, `w`, `mo` or `y` (or the spelled-out forms); others are reported. Placed on the tables its `element` (or `slaDefaultElement`) names. Emitted when `emit_assertions=true`. | -| `support[]` | `institutionalMemory` | Linked as `Support: ()`. Channels without a URL DataHub can store are reported. | -| Typed `servers[]` entry | `logicalParent` on the physical dataset | The `PhysicalInstanceOf` relationship from physical to logical. Platform derives from the spec-required `servers[].type`; names are fully qualified per platform. | -| v3.2 `logicalType: vector` | `ArrayType` schema field | Vector dimensions, element type and model are not recorded. | -| v3.2 `deprecated` (schema object, property) | `deprecation` on the logical dataset / schema field | Explicit `false` clears it; an absent key emits nothing. | -| v3.2 property `synonyms[]` | `aiContext.synonyms` on the schema field | Replaces the field's synonyms. `status: deprecated` entries skipped; `locale` / `source` dropped. | -| v3.2 `semanticType: measure` | Kept in `schemaMetadata`, left out of the schema-compliance assertion | A measure is an aggregate, not a physical column. No metric entity is created. | -| `schema[].properties[]` (entire declared schema) | `SchemaAssertionInfo` (`DATA_SCHEMA` assertion) on the logical dataset | Pins the contract's schema so drift is an evaluable violation. Compatibility defaults to `SUPERSET` (configurable). | -| v3.1 `metric: nullValues` with `mustBe: 0` | `FieldAssertionInfo` + `FieldValuesAssertion` (`NOT_NULL`) | Targets the logical dataset. | -| v3.1 `metric: nullValues` with another threshold | `FieldAssertionInfo` + `FieldMetricAssertion` (`NULL_COUNT` / `NULL_PERCENTAGE`) | `unit: percent` selects the percentage metric. | -| v3.1 `metric: duplicateValues` / v3.0 `rule: duplicateCount` with `mustBe: 0` | `FieldAssertionInfo` + `FieldMetricAssertion` (`UNIQUE_PERCENTAGE` == 100) | Zero duplicates ⇔ fully unique column. | -| v3.1 `metric: invalidValues` / v3.0 `rule: validValues` | `FieldAssertionInfo` + `FieldValuesAssertion` (`IN` or `REGEX_MATCH`) | Allowed values from `arguments.validValues` (or the v3.0 direct `validValues` list); `arguments.pattern` maps to `REGEX_MATCH`. | -| `metric: rowCount` (v3.0 + v3.1) | `VolumeAssertionInfo` | `unit: rows` only; percent-based row counts are preserved as custom assertions. | -| `type: sql` with a `query` and a mappable threshold | `SqlAssertionInfo` | The query's metric is compared with the `mustBe*` operator. | -| All other `quality[]` rules | `CustomAssertionInfo` | Original rule intent preserved verbatim as `logic`. See [Quality rule mapping](#quality-rule-mapping). | +Fields not listed here are not mapped; [Limitations](#limitations) on the module page lists +which of those are reported. Quality rules are covered in +[Quality rules](#quality-rule-mapping). + +| ODCS | DataHub | Notes | +| ------------------------------------------------------------------------ | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` + `schema[].name` | Logical `odcs` Dataset | One per `schema[]` entry, named `{contract_id}.{schema_name}` by default (`logical_dataset_name_template`). | +| `name` + `schema[].name` | `datasetProperties.name` | `" — "` when both are set. | +| `id`, `version`, `apiVersion`, `status`, `domain`, `dataProduct`, … | `datasetProperties.customProperties` | `odcs.id`, `odcs.version`, `odcs.apiVersion`, `odcs.status`, `odcs.schemaName`, `odcs.physicalName`, `odcs.sourceFile`, `odcs.qualityRuleCount`, `odcs.domain`, `odcs.dataProduct`, `odcs.tenant`. | +| Table and contract descriptions, `dataGranularityDescription`, `context` | `datasetProperties.description` | See [Descriptions](#descriptions). | +| `schema[].properties[]` | `schemaMetadata.fields[]` | Nested properties get dotted paths (`address.city`). Unknown types fall back to `NullType` and are reported. | +| Property `required` / `primaryKey` | `nullable` / `isPartOfKey` | `nullable = not required`. | +| Property `description`, `transformLogic`, `enum`, `businessName` | Field description | See [Descriptions](#descriptions). | +| Property `tags[]`, top-level `tags[]` | `globalTags` | `tag_prefix` is prepended when set. Top-level tags follow `replicate_contract_metadata`. | +| `team[]` | `ownership` | Unknown roles become Technical Owner (reported). Members with `dateOut` are skipped. Follows `replicate_contract_metadata`. | +| `authoritativeDefinitions[]` (any level) | `institutionalMemory` | Links DataHub can't store are skipped and reported. | +| Property `authoritativeDefinitions[]` with `type: businessDefinition` | Field glossary term | See [Glossary terms](#glossary-terms). | +| Property `classification` | Field glossary term | `classification-`, or the term `classification_glossary_term_mapping` maps the value to. | +| `slaProperties[]`, `property: latency` | Freshness assertion | Referenced from the data contract. See [SLAs](#slas). | +| `slaProperties[]`, `property: retention` | Dataset glossary term | With `retention_glossary_terms`. See [SLAs](#slas). | +| `support[]` | `institutionalMemory` | `Support: ()`. Channels without a storable URL are reported. | +| Typed `servers[]` entry | `logicalParent` on the physical dataset | See [Physical table resolution](#physical-table-resolution). | +| `status` | `dataContractStatus`, `deprecation` | See [Data contracts](#data-contracts). | +| Whole document | `dataContractProperties.rawContract` | With `data_contract_urn: id`. | +| Declared schema | `DATA_SCHEMA` assertion | See [Schema-compliance assertion](#schema-compliance-assertion). | +| v3.2 `logicalType: vector` | `ArrayType` field | Dimensions, element type and model are not recorded. | +| v3.2 `deprecated` (schema object, property) | `deprecation` on the dataset / field | Explicit `false` clears it. | +| v3.2 property `synonyms[]` | Field `aiContext.synonyms` | Replaces the field's synonyms; `status: deprecated` entries are skipped, `locale` and `source` dropped. | +| v3.2 `semanticType: measure` | Kept in `schemaMetadata`, left out of the schema-compliance assertion | A measure is an aggregate, not a column. No metric entity is created. | diff --git a/metadata-ingestion/docs/sources/odcs/odcs_post.md b/metadata-ingestion/docs/sources/odcs/odcs_post.md index 6ef7a40ddbbda..c0b44a0829e1d 100644 --- a/metadata-ingestion/docs/sources/odcs/odcs_post.md +++ b/metadata-ingestion/docs/sources/odcs/odcs_post.md @@ -1,251 +1,292 @@ ### Capabilities -Use the **Important Capabilities** table above as the source of truth for which DataHub -features this source emits. The notes below cover ODCS-specific behavior that the table -does not capture. +The **Important Capabilities** table above lists what this source emits. The sections below +cover ODCS-specific behaviour. -#### Descriptions +#### Choosing a mapping + +Every `schema[]` entry becomes a dataset, a set of assertions and a data contract. Where they +go depends on two settings. + +| | Logical model (default) | Physical binding | +| ----------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------ | +| Settings | — | `bind_to_physical_dataset: true`, `data_contract_urn: id` | +| Assertions and contract on | A logical `odcs` dataset | The physical table | +| Logical `odcs` dataset | Always | Only for contracts with several servers | +| Link from the physical table | `logicalParent` (`PhysicalInstanceOf`) | `logicalParent` when a logical dataset exists | +| Visible without the beta flag | No | Yes | +| Contract urn | Keyed on the dataset, or on the ODCS id with `id` | Keyed on the ODCS id | +| Use when | Contracts are written before the table exists, or span tables | Each contract describes production tables already in DataHub | + +Logical model, the default: + +```yaml +source: + type: odcs + config: + path: ./contracts/ +``` -The source owns the descriptions of the logical `odcs` dataset and its fields and rebuilds -them from the contract on every run, so re-running never duplicates text and removing a -field from the contract removes its text. Descriptions edited in DataHub are kept and shown -instead. - -- **Dataset:** the table's `description`, then `**Grain:**` with its - `dataGranularityDescription`, then the contract `description` (purpose, usage, - limitations). A contract with several tables repeats the contract description on each. -- **Field:** the property's `description`, then a `**Derivation:**` section with its - `transformDescription` and its `transformLogic` as a SQL block, then `**Allowed values:**` - from the v3.2 `enum` (each value with its `label` and `description`). Values are shown as - text in JSON spelling (`true`, `null`, `1.5`), dates as `2024-01-01`, and a value a single line - can't show exactly (empty, extra blanks, a line break) quoted as JSON, e.g. `""`. An entry with no `value` is dropped and reported. -- **v3.2 `context`:** contract-level and then table-level `context` is appended to the dataset - description as a `**Guidance for AI and analysts:**` section: the instructions (or the string - form), a `**Constraints:**` list from `constraints` and a `**Verified Q&A:**` list from - `verifiedStatements`. Datasets have no AI context aspect, so the description is where people - and Ask DataHub read it. `${VAR}` references in it are kept as written. Entry `id`, `tags`, - `customProperties` and `authoritativeDefinitions` on context entries and enum values are not - recorded. +Physical binding: + +```yaml +source: + type: odcs + config: + path: ./contracts/ + data_contract_urn: id + data_contract_urn_prefix: acme/data-contracts # optional + bind_to_physical_dataset: true +``` + +With physical binding, a bound `schema[]` entry whose table is in DataHub gets its quality, +freshness and schema assertions and its data contract on the physical table, so results +posted to them build one history on the table people use. Nothing else is written onto the +physical dataset: its schema, description, owners and tags stay as its own source ingested +them, and the declared schema lives in the schema assertion and `rawContract`. Glossary terms +are the one addition (see [Glossary terms](#glossary-terms)). + +- Entries that are unbound, or whose table isn't in DataHub, keep the logical mapping. The + table is only checked with a DataHub connection and `verify_physical_urns_exist` on; without + them it's assumed to exist. +- A contract with exactly one server gets no logical dataset. When an entry stops having one, + a `logicalParent` link an earlier run wrote from the table to it is cleared. +- Give every quality rule an `id`. Rules without one are reported, because their assertion + history only survives while the rule's name and position stay the same. +- `bind_to_physical_dataset` requires `data_contract_urn: id`, so the contract can't replace a + hand-written one on the table, and `emit_logical_parent`, the switch for writing onto + physical datasets. +- Domains are only set on logical datasets, so a one-server contract gets none (reported). +- Two contracts bound to one table are reported. + +#### Data contracts + +One native `dataContract` is emitted per `schema[]` entry (`emit_data_contract`, on by +default) and shows on the **Contract** tab. It references the entry's schema, quality and +freshness assertions without duplicating them, and is skipped when the entry has no +assertions. + +**Contract urns** + +| `data_contract_urn` | Urn | Goes on | Owned by ODCS | +| ------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `entity` (default) | Derived from the dataset, as the DataHub SDK does | The logical dataset; also the bound physical table with `emit_physical_data_contract` | The logical one only; the physical copy can be hand-written, so it's never stale-removed | +| `id` | `urn:li:dataContract:[/]/` | The physical table with `bind_to_physical_dataset` or `emit_physical_data_contract`, else logical | Yes, managed by stale removal | + +With `entity`, the logical contract only renders under `LOGICAL_MODELS_ENABLED`, so the table +people browse has no contract until the flag is on or `emit_physical_data_contract` is set +(which needs `emit_logical_parent`). The physical contract's urn is the one a hand-written +contract on that table would use, so enabling it makes ODCS the owner of that table's +contract, and two contracts bound to one table share it. + +With `id`: + +- `data_contract_urn_prefix` (e.g. `/`) only needs ids to be unique per repository. +- Characters DataHub reserves in urns are percent-encoded, and so is a `/` inside the id or + schema name. A urn longer than 512 bytes is skipped with a warning; the dataset and + assertions are still emitted. +- `rawContract` holds the full YAML, with `user:password@` in URLs redacted. +- An ODCS id used by two files is reported. +- Switching an existing source from `entity` to `id` replaces the contracts on its logical + datasets, which stale removal soft-deletes on the next run. A contract an earlier run wrote + on a physical table is left in place. + +**Contract status** + +DataHub has no deprecated contract state, so ODCS `status` maps like this: + +| ODCS `status` | Contract state | Logical dataset | Notes | +| -------------------------- | -------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `active` | `ACTIVE` | — | | +| `deprecated` | `ACTIVE` | Deprecated | Still in force until retired. | +| `retired` | Not emitted | Deprecated | The contract an earlier run emitted is soft-deleted (with a DataHub connection, or by stale removal). A dataset-keyed contract on a physical table may be hand-written, so it's only reported. | +| `proposed`, `draft`, other | `PENDING` | — | | + +When a contract is active again, the deprecation ODCS set is cleared; this needs a DataHub +connection, and its absence is reported. A deprecation set by hand in DataHub stays. A +one-server contract bound to its table has no logical dataset to deprecate, so its status is +only reported, never written onto the table. The status itself is kept in `odcs.status`. + +#### Physical table resolution + +Each `schema[]` entry is resolved to a physical table in this order: + +1. `physical_urn_overrides[][]`: an explicit dataset urn, or + `""` to leave the entry unbound on purpose. Names absent from the map fall back to step 2; + keys matching no entry are reported. A value that isn't a dataset urn with a known env + (`PROD`, not `prod`), or contains `${VAR}`, leaves the entry unbound with a warning. +2. The contract's first server whose `type` maps to a platform. The table name + (`physicalName`, else `name`) is qualified with the server's own fields: + +| Server `type` | DataHub platform | Physical name | +| ------------- | ------------------- | ----------------------------------------------------------------- | +| `postgres` | `postgres` | `database.schema.table` | +| `redshift` | `redshift` | `database.schema.table` | +| `sqlserver` | `mssql` | `database.schema.table` | +| `snowflake` | `snowflake` | `database.schema.table`, lowercased | +| `bigquery` | `bigquery` | `project.dataset.table` | +| `databricks` | `databricks` | `catalog.schema.table` | +| `trino` | `trino` | `catalog.schema.table` | +| `mysql` | `mysql` | `database.table` | +| `oracle` | `oracle` | Not composable: use a dotted `physicalName` or an override | +| `glue` | `glue` | `database.table`, lowercased | +| `iceberg` | `glue` or `iceberg` | `namespace.table` | +| anything else | — | Unbound; the logical dataset and its assertions are still emitted | + +- `server_overrides` refines `env`, `platform_instance` or `platform` per `servers[].server` + (`match_any: true` for a catch-all). +- Snowflake and Glue names are lowercased to match their connectors; + `lowercase_physical_urns: false` turns that off for both. +- An `iceberg` server binds to `glue` when its `catalogUrl` is an AWS Glue host + (`glue..amazonaws.com`, including FIPS and China endpoints, with or without + `https://`) and `warehouse` is absent or the account id; the namespace is then the Glue + database. A `warehouse` naming another catalog (such as S3 Tables, + `:s3tablescatalog/`) leaves it unbound. Any other `catalogUrl` binds to + `iceberg`. A `server_overrides` platform replaces this choice, still with `namespace.table`. +- `glue` servers weren't mappable before v3.2 support, so a v3.0/v3.1 contract listing a + `glue` server before another mappable one now binds to the Glue table. +- A `physicalName` that already contains a dot is used as written + (`report.physical_names_passthrough`). +- Missing server fields leave the entry unbound with the reason; a schema name is never + guessed. A server refused for an unresolved `${VAR}` stops the search. +- With a DataHub connection and `verify_physical_urns_exist` on, a table not in DataHub is + left unbound with a warning rather than created as a stub. With a file sink there's no + check. +- `logicalParent` is single-valued: two entries binding one table, in one run or across runs, + are reported, and the last one wins. #### Quality rule mapping -Each entry in a `schema[]` (table-level) or `properties[]` (column-level) `quality[]` array -becomes a DataHub assertion **attached to the logical `odcs` dataset**, emitted whether or -not a physical binding resolves. The library vocabulary is spec-exact and -version-dependent: - -| ODCS rule | DataHub aspect | -| --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -| v3.1 `metric: nullValues` with `mustBe: 0` | `FieldAssertionInfo` + `FieldValuesAssertion` (`NOT_NULL`) | -| v3.1 `metric: nullValues` with another threshold | `FieldAssertionInfo` + `FieldMetricAssertion` (`NULL_COUNT` / `NULL_PERCENTAGE`) | -| v3.1 `metric: duplicateValues` / v3.0 `rule: duplicateCount` with `mustBe: 0` | `FieldAssertionInfo` + `FieldMetricAssertion` (`UNIQUE_PERCENTAGE` == 100) | -| v3.1 `metric: invalidValues` (`arguments.validValues`) / v3.0 `rule: validValues` | `FieldAssertionInfo` + `FieldValuesAssertion` (`IN`) | -| v3.1 `metric: invalidValues` with `arguments.pattern` | `FieldAssertionInfo` + `FieldValuesAssertion` (`REGEX_MATCH`) | -| `metric: rowCount` (v3.0 `rule: rowCount`) | `VolumeAssertionInfo` (`unit: rows` only) | -| `type: sql` with a `query` and a mappable threshold | `SqlAssertionInfo` | -| `type: custom` (`engine` + `implementation`) | `CustomAssertionInfo` (`type` = the engine, `logic` = the implementation) | -| `type: text` | `CustomAssertionInfo` (`logic` = the description) | -| Anything else with content | `CustomAssertionInfo` (original rule intent preserved as `logic`) | -| Anything with no operator and no body | Skipped with a warning | - -The v3.1 library key is `metric`; `rule` is accepted as the v3.0 canonical key and as the -deprecated v3.1 alias (v3.1 documents using `rule` get an informational notice). Every -assertion carries ODCS provenance in `customProperties` (`odcs.id`, `odcs.rule.id`, -`odcs.rule.metric`, `odcs.rule.unit`, serialized `odcs.rule.arguments`, dimension / -severity / businessImpact when present), a `dataPlatformInstance` aspect attributing it to -the `odcs` platform, and an `externalUrl` from the rule's `authoritativeDefinitions` when -provided. Assertion URNs are seeded from the spec's `quality.id` when present, so renames -and reordering do not churn identities. - -When a table binds to a physical dataset, `{object}` and `${object}` in a rule's `query` -are replaced with the bound table's name, for example `my_catalog.my_schema.orders`, without -the platform instance. The name is not quoted. A name derived from `servers[]` is lowercased -when `lowercase_physical_urns` lowercases the URN. A `physical_urn_overrides` URN's dataset -name is used as written, minus the platform instance of the contract's server when that -server's `server_overrides` entry sets one on the same platform. If the name may instead start -with a `server_overrides` instance that the contract's server doesn't account for (any case, -on the same platform or one left unset), its SQL name is unknown, so the placeholder is kept -and reported. With `verify_physical_urns_exist`, a table that is -not found in DataHub is not substituted. A table that is not bound or not found keeps the -placeholder and gets a warning, unless it was unbound on purpose with an empty -`physical_urn_overrides` entry. An override value that is not a dataset URN with a known env (`PROD`, not -`prod`), or that contains `${VAR}`, leaves the table unbound with a warning (a `${VAR}` value is reported, and counted, -as an unresolved variable). Placeholders in `implementation` are not -replaced and are reported as unresolved variables. `{{object}}` is left as written. - -:::warning Routing is exact; nothing is approximated - -Tolerances map to typed assertions only when they are exactly representable: - -- No threshold at all (the v3.0 `validValues` form) and `mustBe: 0` both mean "no failing - rows tolerated". -- An integral `mustBeLessOrEqualTo` maps to a fail threshold in rows (`unit: rows`) or - percent (`unit: percent`). -- Everything else — strict less-than tolerances, non-integral percents, - `mustNotBeBetween`, duplicate-count tolerances, percent-based `rowCount`, multi-column - `duplicateValues` (`arguments.properties`), `missingValues` — is preserved as a - `CustomAssertionInfo` whose `logic` carries a stable rendition of the original rule - (metric, arguments, thresholds, unit) rather than being approximated into a typed shape. -- Rules routed to custom are listed in `report.rules_routed_to_custom`; rules with no - modelable content at all are skipped and listed in `report.rules_skipped_no_threshold`. +Each `quality[]` rule, at table or column level, becomes an assertion on the entry's dataset, +whether or not a physical table resolves. + +| ODCS rule | DataHub assertion | +| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | +| v3.1 `metric: nullValues` with `mustBe: 0` | `FieldAssertionInfo` + `FieldValuesAssertion` (`NOT_NULL`) | +| v3.1 `metric: nullValues` with another threshold | `FieldAssertionInfo` + `FieldMetricAssertion` (`NULL_COUNT`, or `NULL_PERCENTAGE` with `unit: percent`) | +| v3.1 `metric: duplicateValues` / v3.0 `rule: duplicateCount` with `mustBe: 0` | `FieldAssertionInfo` + `FieldMetricAssertion` (`UNIQUE_PERCENTAGE` == 100) | +| v3.1 `metric: invalidValues` (`arguments.validValues`) / v3.0 `rule: validValues` | `FieldAssertionInfo` + `FieldValuesAssertion` (`IN`) | +| v3.1 `metric: invalidValues` with `arguments.pattern` | `FieldAssertionInfo` + `FieldValuesAssertion` (`REGEX_MATCH`) | +| `metric: rowCount` (v3.0 `rule: rowCount`) | `VolumeAssertionInfo` (`unit: rows` only) | +| `type: sql` with a `query` and a mappable threshold | `SqlAssertionInfo` | +| `type: custom` (`engine` + `implementation`) | `CustomAssertionInfo` (`type` = the engine, `logic` = the implementation) | +| `type: text` | `CustomAssertionInfo` (`logic` = the description) | +| Anything else with content | `CustomAssertionInfo` (the original rule as `logic`) | +| No operator and no body | Skipped with a warning (`report.rules_skipped_no_threshold`) | + +:::warning Thresholds are mapped exactly or not at all + +- No threshold (the v3.0 `validValues` form) and `mustBe: 0` both mean no failing rows. +- An integral `mustBeLessOrEqualTo` becomes a fail threshold in rows (`unit: rows`) or percent + (`unit: percent`). +- Everything else becomes a `CustomAssertionInfo` carrying the metric, arguments, thresholds + and unit, listed in `report.rules_routed_to_custom`: strict less-than tolerances, + non-integral percents, `mustNotBeBetween`, duplicate-count tolerances, percent row counts, + multi-column `duplicateValues` (`arguments.properties`) and `missingValues`. ::: +- The v3.1 key is `metric`. `rule` is accepted as the v3.0 key and as a deprecated v3.1 alias, + with an info for v3.1 contracts. +- Each assertion carries `odcs.id`, `odcs.rule.id`, `odcs.rule.metric`, `odcs.rule.unit` and + serialized `odcs.rule.arguments` (plus dimension, severity and businessImpact when set) in + `customProperties`, a `dataPlatformInstance` for `odcs`, and an `externalUrl` from the + rule's `authoritativeDefinitions`. +- Assertion urns come from the contract id, the rule's `id` and the target dataset, so + renaming or reordering rules keeps them. +- Uniqueness is only checked through a rule (`metric: duplicateValues` with `mustBe: 0`); + property `unique: true` isn't mapped. + +**`{object}` in SQL rules.** When the entry is bound, `{object}` and `${object}` in a rule's +`query` become the table's name without the platform instance (e.g. +`my_catalog.my_schema.orders`), unquoted, and lowercased when `lowercase_physical_urns` +lowercased the urn. An override urn's name is used as written, minus the contract server's +platform instance when its `server_overrides` entry sets one on the same platform. When the +name might start with another `server_overrides` instance on that platform (or on one left +unset), its SQL name is unknown, so the placeholder is kept and reported. A table that isn't +bound, or isn't found with `verify_physical_urns_exist`, keeps the placeholder with a warning, +unless it was unbound on purpose with `""`. Placeholders in `implementation` aren't replaced +and are reported as unresolved variables; `{{object}}` is left as written. + #### Schema-compliance assertion -For every `schema[]` entry that declares properties, the source emits one `DATA_SCHEMA` -assertion (`SchemaAssertionInfo`) on the logical dataset carrying the contract's declared -schema. This makes schema drift an evaluable contract violation rather than an implied -one. `schema_assertion_compatibility` controls the mode: `SUPERSET` (default — an instance -must contain at least the contract's fields, extras allowed), `EXACT_MATCH`, or `SUBSET`. -Disable with `emit_schema_assertion: false`. - -#### Physical dataset binding (the `logicalParent` link) - -Binding exists to link physical datasets to their logical model — assertions never depend -on it. Resolution per `schema[]` entry, in priority order: - -1. `physical_urn_overrides[][]` — an explicit URN, or an - empty string to deliberately leave the entry unbound. Entries absent from the map fall - back to derivation; keys that match no schema entry warn. A value that is not a dataset - URN leaves the entry unbound and is reported as a warning. -2. The contract's first mappable `servers[]` entry. The platform comes from the - spec-required `servers[].type` (or a matching `server_overrides` entry), and the table - name (`physicalName`, falling back to `name`) is qualified with the server's own fields - per the platform's URN convention: - -| Server `type` | DataHub platform | Physical name | -| ------------- | ------------------------------ | ------------------------------------------------------------------------------------------ | -| `postgres` | `postgres` | `database.schema.table` | -| `redshift` | `redshift` | `database.schema.table` | -| `sqlserver` | `mssql` | `database.schema.table` | -| `snowflake` | `snowflake` | `database.schema.table` (lowercased by default; `lowercase_physical_urns: false` opts out) | -| `bigquery` | `bigquery` | `project.dataset.table` | -| `databricks` | `databricks` | `catalog.schema.table` | -| `trino` | `trino` | `catalog.schema.table` | -| `mysql` | `mysql` | `database.table` | -| `oracle` | `oracle` | not composable — supply a dotted `physicalName` or an explicit override | -| `glue` | `glue` | `database.table`, lowercased (see note) | -| `iceberg` | `glue` or `iceberg` (see note) | `namespace.table` | -| anything else | — | unbound (logical dataset and assertions unaffected) | - -Notes on `glue` and `iceberg`: - -- Glue stores names in lowercase, so composed `glue` names are lowercased - (`lowercase_physical_urns: false` opts out). -- An `iceberg` server binds to `glue` when its `catalogUrl` is an AWS Glue host - (`glue..amazonaws.com`, including FIPS and China endpoints, with or without - `https://`) and `warehouse` is absent - or the account ID; the namespace is then the Glue database. A `warehouse` naming another - catalog (for example S3 Tables, `:s3tablescatalog/`) leaves the entry - unbound. Any other `catalogUrl` binds to `iceberg`. A `server_overrides` platform replaces - this choice but the name is still `namespace.table`. -- `glue` server entries were unmappable before v3.2 support. A v3.0/v3.1 contract that lists a - `glue` server before another mappable server now binds to the Glue table. - -A `physicalName` that already contains a dot is used verbatim (assumed pre-qualified) and -counted in `report.physical_names_passthrough`. Missing server fields leave the entry -unbound with an actionable reason — the source never guesses a schema name. When a DataHub -graph is available and `verify_physical_urns_exist` is on (default), derived URNs that do -not exist in DataHub are left unbound with a warning instead of creating stub datasets. -Two schema entries binding the same physical dataset warn: `logicalParent` is -single-valued, so the last writer wins. +Each `schema[]` entry with properties gets one `DATA_SCHEMA` assertion carrying the declared +schema, so schema drift becomes an evaluable violation. Measures (`semanticType: measure`) are +left out of it. -#### Data product output ports +| `schema_assertion_compatibility` | An instance must | +| -------------------------------- | -------------------------------------- | +| `SUPERSET` (default) | Contain at least the contract's fields | +| `EXACT_MATCH` | Have exactly the contract's fields | +| `SUBSET` | Have no fields beyond the contract's | -In the Bitol model a data product is authored separately (ODPS) and lists its contracts -under `outputPorts` — the interfaces it promises to consumers. ODCS carries only the -back-reference, a free-text `dataProduct` field. With -`emit_data_product_association: true` the source follows that back-reference: the dataset -each contract governs is added to the named Data Product **as an output port** -(`outputPort: true`), which is what the product page's Output Ports module, the lineage -"output ports only" filter, and the search-preview pill read. - -The asset added is the **physical dataset** when the contract binds to one — that is the -table consumers actually query, and it renders without the Logical Models beta flag. An -unbound contract contributes its logical `odcs` dataset instead. The DataContract entity -itself is never the asset: DataHub's `DataProductContains` relationship accepts datasets, -jobs, dashboards and the like, not contracts. - -The product is expected to exist already, so the `dataProduct` value is resolved against -DataHub in order: - -1. a full `urn:li:dataProduct:...` value, used verbatim; -2. `urn:li:dataProduct:`, when a product exists under that id; -3. an exact, case-insensitive match on a product's **display name** — ODCS documents the - field as the product's name, and a name like `Orders, Retail (EU)` can never be an id - because commas and parens are structural in DataHub urns. - -A value matching nothing is reported (`report.data_products_unresolved`) and skipped rather -than turned into a stub product. A name carried by more than one product is ambiguous and -also skipped — set `dataProduct` to the intended product's id. Values resolved by name are -counted in `report.data_products_resolved_by_name`; with a file sink there is no graph to -resolve against, so the id-derived urn is used unverified. - -Set `verify_data_product_exists: false` for a contract-first workflow, where ODCS creates -the product at `urn:li:dataProduct:`, names it after the value, and marks it not -removed. The id is the value itself rather than a generated guid, exactly as -`datahub dataproduct upsert` derives a urn from a product's `id` — so a product ODCS -created can later be taken over from a DataProduct yaml, and a product created that way is -found by ODCS. The name is written only for a product this run creates; on a product that -already exists ODCS never touches its display name. - -Every contract naming the same product contributes to one patch per run, so a product -assembled from several contracts gets a single update. Because the patch is additive, ODCS -never clears assets it did not add and the product is never stale-removed — dropping the -`dataProduct` field, or a whole contract, leaves the port in place; remove it in the UI or -via the DataProduct SDK. An asset the product already carries is promoted to an output port -in place. +`emit_schema_assertion: false` turns it off. -#### Domains +#### SLAs + +**`latency`** becomes a freshness assertion, referenced from the data contract (with +`emit_assertions`). It's declared, not run. -ODCS names a contract's data domain in the free-text `domain` field (there is no sub-domain -field). With `emit_domain_association: true` the source sets that DataHub Domain on the -contract's **logical `odcs` datasets**. Physical datasets are never touched, because their -domain is often set by another connector or by hand. - -The value is resolved against DataHub in order: - -1. the value as an id: a full `urn:li:domain:...` value, or `urn:li:domain:`, when a - domain exists under that urn; -2. an exact, case-insensitive match on a domain's **name**. Domains created in the UI get - generated ids, so this is how a value like `Sales` finds them. - -A name carried by more than one domain (for example, same-named sub-domains under different -parents) is ambiguous and skipped with a warning; set `domain` to the intended domain's id. A -value that is a urn but not a plain Domain urn (another entity's urn, odd casing) is never -read as an id. - -When nothing matches, ODCS **creates** the domain at `urn:li:domain:`, named after its -id (the value itself, or the id part of a full urn), with a description noting that the ODCS -connector created it (`report.domains_created`). Creation needs a DataHub graph that has -confirmed the domain is absent, and a value that forms a valid id. A value that cannot (for -example, one containing commas or parentheses) must match an existing domain by name. -Values that differ only in case reuse the domain created earlier in the same run. Set -`verify_domain_exists: true` to report a missing domain instead of creating it. Unlike -`verify_data_product_exists`, it defaults to `false`, because a domain is a simple grouping -that is safe to create from a contract. - -ODCS never rewrites the name or description of an existing domain and never stale-removes a -domain, even one it created. A failed lookup is reported (`report.domains_unresolved`), -creates nothing, and leaves the datasets' current domain in place, so a transient error can -neither produce a duplicate nor replace a domain. With a file sink there is no graph: the -id-derived urn is set unverified with a warning, and nothing is created. - -With the option on, the contract owns the logical dataset's domain: dropping `domain` from a -contract clears it on the next run. An unresolved value leaves the current domain in place. +- It needs a whole positive `value` and a `unit` of `min`, `h`, `d`, `w`, `mo` or `y` (or the + spelled-out forms). `30 s`, `1.5 h`, `PT1H`, a bare `m` or a value too large for an interval + is reported. +- It goes on each table its `element` (or `slaDefaultElement`) names: the table (`table`, + `table.column`), one of its columns (dotted path such as `address.street`, or + `physicalName`), or `.column`. No element means every + table. One matching no table is reported. +- Its urn follows the SLA's `id` when set; a repeat of an earlier SLA is reported and skipped. +- `element` and `driver` are kept as `odcs.sla.element` and `odcs.sla.driver`. + +**`retention`** becomes a dataset glossary term with `retention_glossary_terms`. An SLA +applies when it's contract-wide or its element names the table or one of its columns +(`orders.created_at`); with several, the longest retention counts. The entry with the largest +`min_days` not above it is used. A week is 7 days, a year 365 and a month a twelfth of a year, +so 13 months is 395 days. + +```yaml +retention_glossary_terms: + - min_days: 365 + term: urn:li:glossaryTerm:Retention.1Year + - min_days: 395 + term: urn:li:glossaryTerm:Retention.13Months +``` + +Retentions that aren't a finite number of days, match no table, or are below every entry are +reported. Thresholds must be unique. + +Other SLA properties (frequency, availability, …) aren't recorded; they're listed as +`.slaProperties[property=]` in `report.spec_fields_ignored`. + +#### Descriptions + +The source rebuilds the descriptions of the logical dataset and its fields from the contract +on every run, so text never duplicates and removed fields lose theirs. Descriptions edited in +DataHub are kept and shown instead. + +| Description | Built from, in order | +| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Dataset | The table's `description`; `**Grain:**` from `dataGranularityDescription`; the contract `description` (purpose, usage, limitations), repeated on each table; v3.2 `context`, contract-level then table-level, as `**Guidance for AI and analysts:**` | +| Field | The property's `description`; `**Derivation:**` from `transformDescription` with `transformLogic` as a SQL block; `**Allowed values:**` from the v3.2 `enum`; `**Business name:**` | + +- `context` contributes its instructions (or string form), a `**Constraints:**` list and a + `**Verified Q&A:**` list from `verifiedStatements`. Datasets have no AI context aspect, so + the description is where people and Ask DataHub read it. `${VAR}` in it is kept as written. +- `enum` values show in JSON spelling (`true`, `null`, `1.5`), dates as `2024-01-01`, each with + its `label` and `description`. A value one line can't show exactly (empty, extra blanks, a + line break) is quoted as JSON, e.g. `""`. An entry with no `value` is dropped and reported. +- `businessName` is skipped when it only re-cases the column name (`OrderId` for `order_id`). +- Entry `id`, `tags`, `customProperties` and `authoritativeDefinitions` on context entries and + enum values aren't recorded. #### Glossary terms -A property's `classification`, and each of its `authoritativeDefinitions` with -`type: businessDefinition` whose `url` is not a web link or a path, become glossary terms on -the field. A reference becomes a term urn by one fixed rule: a `urn:li:glossaryTerm:` urn is -used as is; anything else is trimmed and lowercased, each `:` becomes `-` (whitespace around -it is dropped), and other runs of whitespace become `_`. Letters and digits in any script, -`_`, `-` and `.` are kept as they are. A reference containing any other character (such as -`+`, `&` or parentheses), or with nothing on one side of a `:`, names no term: it is -reported as a skipped term reference rather than mapped, so distinct references never -collapse onto one term. A classification is resolved as `classification:`. +A property's `classification`, and its `authoritativeDefinitions` with +`type: businessDefinition` whose `url` isn't a web link or a path, become field glossary +terms. A reference becomes a term urn by one rule: a `urn:li:glossaryTerm:` urn is used as is; +anything else is trimmed and lowercased, `:` becomes `-` (dropping the whitespace around it) +and other whitespace runs become `_`. Letters and digits in any script, `_`, `-` and `.` are +kept. Any other character (`+`, `&`, parentheses, …), or nothing on one side of a `:`, means +no term, reported as skipped, so distinct references never collapse onto one term. | Contract value | Glossary term | | -------------------------------- | ------------------------------------------------- | @@ -255,18 +296,11 @@ collapse onto one term. A classification is resolved as `classification:` | `url: "urn:li:glossaryTerm:a.b"` | `urn:li:glossaryTerm:a.b` | | `classification: confidential` | `urn:li:glossaryTerm:classification-confidential` | | `classification: 機密` | `urn:li:glossaryTerm:classification-機密` | -| `classification: A+` | none: reported as skipped | - -Create the terms with these ids (for example with a business glossary file) for the -references to resolve. The source never creates terms: it does not emit the key aspect -DataHub would otherwise add for a referenced term, and with a DataHub graph available -(datahub-rest sink) it warns once per term that does not exist. Only property-level -references are mapped; a business definition at contract or schema level that is not a web -link is reported as a skipped link. +| `classification: A+` | None, reported as skipped | -To use your own classification terms, map each value to a term urn with -`classification_glossary_term_mapping`. Values are matched case-insensitively; a value -missing from the map keeps the `classification-` term and is reported: +To use your own classification terms instead, map each value (case-insensitively) with +`classification_glossary_term_mapping`. A value missing from the map keeps the +`classification-` term and is reported; two keys differing only by case are rejected. ```yaml classification_glossary_term_mapping: @@ -274,225 +308,231 @@ classification_glossary_term_mapping: public: urn:li:glossaryTerm:Tier.Public ``` -A `retention` SLA can add a term to the dataset with `retention_glossary_terms`. An SLA -applies to a table when it is contract-wide or its element names the table or one of its -columns (`orders.created_at`); with several, the longest retention counts. The entry with the -largest `min_days` that is not above that retention is used. A week is 7 days, a year 365 and -a month a twelfth of a year, so 13 months is 395 days: +- Terms are referenced, never created: create them (for example with a business glossary + file) for the references to resolve. With a DataHub connection, a missing term is reported + once. +- Only property-level references are mapped. A contract- or schema-level business definition + that isn't a web link is reported as a skipped link. -```yaml -retention_glossary_terms: - - min_days: 365 - term: urn:li:glossaryTerm:Retention.1Year - - min_days: 395 - term: urn:li:glossaryTerm:Retention.13Months -``` +**Terms written by patch.** Retention terms, and column terms on a table bound with +`bind_to_physical_dataset`, are patched and attributed to the data contract. Each run replaces +only the terms that contract gave, so terms from people or other sources stay. + +- Physical column terms need a DataHub connection: the table's columns are read and matched by + physical name, exactly or else ignoring case when only one column fits. Other columns, and a + table with no schema in DataHub, are reported instead of written. +- With stateful ingestion, the run ends by removing the contract's terms from any column, + table or contract it no longer writes to (a dropped column, a retired or deleted contract, a + table no longer bound), unless a file couldn't be read. Without stateful ingestion this + cleanup doesn't happen, and that's reported. + +#### Owners and tags -Retention terms, and column terms on a table bound with `bind_to_physical_dataset`, are -added by patch and attributed to the data contract. Each run replaces only the terms that -contract gave the dataset or column, so terms added by people or by other sources stay. On a -physical table, column terms need a DataHub connection: the source reads the table's columns -and matches each by physical name, exactly or else ignoring case when only one column fits; -other columns are reported instead of written. With stateful ingestion, terms on a column, -table or contract a run no longer writes to (a dropped column, a retired or deleted contract, -a table no longer bound) are removed at the end of the run, unless a file could not be read. +Contract-level owners (`team[]`) and top-level tags are written to each logical dataset on +every run, replacing edits made in DataHub. With `replicate_contract_metadata: false` they're +not written at all, so UI edits stay. Schema-entry and property tags are always written. -#### What changes for existing users +`team[].username` is a username or an email, and must match how your identity source keys +users. Set one of these to normalise it (explicit `urn:li:corpuser:` and `urn:li:corpGroup:` +values pass through): -There are no new config options. Re-ingesting a contract now adds: +| Setting | Effect | +| -------------------------------- | ----------------------------------- | +| `strip_owner_email_domain: true` | `alice@acme.com` → corpuser `alice` | +| `owner_email_domain: acme.com` | `alice` → corpuser `alice@acme.com` | -- a freshness assertion per `latency` SLA, referenced from the logical `dataContract`'s - `freshness` (with `emit_assertions`, the default); -- `support` channels as links on the logical dataset; -- glossary terms on fields, from `classification` and business definitions; -- a `**Business name:**` section in field descriptions. +With a DataHub connection, owners that don't resolve are reported +(`report.owners_unresolved`, once each) but still written, and work once the user exists. -Property-level business definitions such as `term:order_line` are no longer reported as -skipped links. Latency SLAs that cannot be placed or converted, and support channels -without a link, are now reported. +#### Domains + +`emit_domain_association: true` sets the DataHub Domain named by the contract's free-text +`domain` on its logical datasets. Physical datasets are never touched, since another source or +a person often sets their domain. ODCS has no sub-domain field. + +The value resolves in this order: + +1. As an id: a full `urn:li:domain:...` value, or `urn:li:domain:`, when that domain + exists. A urn that isn't a plain Domain urn (another entity's, odd casing) is never read + as an id. +2. An exact, case-insensitive match on a domain's name, which is how a value like `Sales` + finds a domain created in the UI with a generated id. A name shared by several domains (such + as same-named sub-domains) is ambiguous and skipped with a warning. + +When nothing matches, ODCS creates `urn:li:domain:`, named after the id, with a +description saying the ODCS connector created it (`report.domains_created`). That needs a +DataHub connection that confirmed the domain is absent, and a value that forms a valid id; +values with commas or parentheses must match by name. Values differing only in case reuse a +domain created earlier in the run. `verify_domain_exists: true` reports a missing domain +instead. It defaults to `false`, unlike `verify_data_product_exists`, because a domain is a +simple grouping that's safe to create. + +- The contract owns the domain: removing `domain` clears it on the next run, including one set + by hand. An unresolved value leaves the current domain. +- ODCS never renames, redescribes or stale-removes a domain, even one it created. +- A failed lookup is reported (`report.domains_unresolved`), creates nothing and leaves the + current domain, so a transient error can't create a duplicate or swap a domain. +- With a file sink there's no connection: the id-derived urn is set unverified with a warning, + and nothing is created. + +#### Data product output ports + +In the Bitol model a data product is authored separately (ODPS) and lists its contracts under +`outputPorts`; ODCS only carries the free-text `dataProduct` back-reference. +`emit_data_product_association: true` adds the dataset each contract governs to that product +**as an output port** (`outputPort: true`), which the product page's Output Ports module, the +lineage "output ports only" filter and the search preview read. + +- The asset is the physical table when the contract binds to one (it renders without the + beta flag), otherwise the logical dataset. The contract itself is never the asset: + `DataProductContains` takes datasets, jobs, dashboards and the like, not contracts. +- The value resolves to a full `urn:li:dataProduct:...` value, then `urn:li:dataProduct:` + when that product exists, then an exact case-insensitive display-name match. A name like + `Orders, Retail (EU)` can only match by name, since commas and parentheses can't appear in + an id. +- Nothing matching is reported (`report.data_products_unresolved`) and skipped; a name shared + by several products is skipped too. Name matches are counted in + `report.data_products_resolved_by_name`. With a file sink the id-derived urn is used + unverified. +- `verify_data_product_exists: false` is for contract-first workflows: ODCS creates the product + at `urn:li:dataProduct:`, named after the value and not removed. That's the urn + `datahub dataproduct upsert` derives from a product id, so the product can later be taken + over from a DataProduct YAML, and one created that way is found by ODCS. The name is only + written on a product this run creates. +- All contracts naming a product go into one additive patch per run, so ODCS never clears + assets it didn't add and never stale-removes the product. Dropping `dataProduct`, or the + contract, leaves the port; remove it in the UI or with the DataProduct SDK. An asset the + product already has is promoted to an output port in place. + +#### Filtering + +`dataset_pattern` allow and deny regexes match the composed logical dataset name +(`{contract_id}.{schema_name}`, per `logical_dataset_name_template`), ignoring case by +default. A non-matching entry is skipped with its assertions and link, and listed in +`report.filtered`. Deny wins over allow. `path` globs, by contrast, filter by file location. + +#### Stale metadata removal + +With a `stateful_ingestion` block (server-side checkpoints, needs a DataHub connection), +removing a `schema[]` entry or file soft-deletes what ODCS owns on the next run. The +`fail_safe_threshold` guard (75% by default) blocks mass deletions from config or naming +changes. + +| Removed by stale removal | Never removed | +| ------------------------------------------------------ | ------------------------------------------------------- | +| Logical `odcs` datasets and their assertions | Physical datasets and the `logicalParent` links on them | +| Contracts on logical datasets, and all `id`-keyed ones | Dataset-keyed contracts on physical tables | +| Assertions on physical tables | Data products and domains, including ones ODCS created | + +Glossary terms are removed separately, see [Glossary terms](#glossary-terms). ### Limitations -- ODCS v3.0, v3.1 and v3.2 only. Contracts reporting v2.x in `apiVersion` are skipped with a - warning. -- **Logical Models are in private beta** and render in the UI only when - `LOGICAL_MODELS_ENABLED` is enabled (off by default). The logical datasets and their - assertions are ingested while the flag is off — they just aren't displayed. -- **Nested-column assertions and field-path resolution.** Field-scoped assertions reference - the column by its dotted property path (`address.city`), matching the logical dataset's - own `schemaMetadata`. Propagation onto physical datasets whose connectors encode nested - struct paths differently is subject to the platform propagation mechanism. -- **Property-level `required` / `primaryKey` map into `schemaMetadata`** (nullability, - keys); `unique: true` is not mapped and is not checked by the schema-compliance assertion. - Express uniqueness as a `quality[]` rule (`metric: duplicateValues` with `mustBe: 0`) to get - a typed field assertion. -- `authoritativeDefinitions` URLs that DataHub can't store as links (relative paths such as - `../docs/orders.md`, schemes other than http, https, ftp and mailto, or URLs containing - spaces or characters such as `|`, `{` and `}`) are skipped and reported in one warning per - file. -- File loading is capped at 5 MB by default (`max_input_file_bytes`). Larger YAML files - are skipped with a warning before parsing. -- Out of scope: `price`, `roles`, SLA properties other than `latency`, property - `criticalDataElement`, v3.1 `relationships` (foreign keys), `customProperties` → DataHub - `customProperties` (only the `odcs.*` provenance subset is emitted), schemaField-level - `logicalParent` column links, and ODCS export. Spec-valid fields the source does not map - are reported once per file as an info and listed in `report.spec_fields_ignored` - (unmapped SLA properties as `.slaProperties[property=]`). Besides whole - sections such as price and roles, these include fields the source reads but does not - map: `unique`, `primaryKeyPosition`, `partitioned`, `partitionKeyPosition`, - `criticalDataElement`, `encryptedName` and `physicalName` on properties, `businessName` - on schema objects, `contractCreatedTs`, quality-rule `method` / `schedule` / - `scheduler`, team-member `dateIn` / `replacedByUsername`, server `environment` / - `location` / `region`, SLA `valueExt` / `schedule` / `scheduler`, and support - `invitationUrl`. These may land in a follow-up. -- **SLA freshness assertions are declared, not run.** Like the quality-rule assertions, the - freshness assertion from a `latency` SLA records the contract's promise on the logical - dataset; the SLA's `element` and `driver` are kept in the assertion's `odcs.sla.element` - and `odcs.sla.driver` properties. It is placed on a table when its element names the - table (`table` or `table.column`), a column of it (by dotted path such as - `address.street`, or `physicalName`), or names no table of the contract but a column of - that table (`.column`); an SLA without an element applies to every table. A latency SLA - that matches no table, cannot be read as a whole interval (`30 s`, `1.5 h`, `PT1H`, bare - `m`, values too large for an interval), or repeats an earlier one is reported as a warning, - once per contract. The assertion's urn follows the - SLA's `id` when it has one. `retention` SLAs become glossary terms with - `retention_glossary_terms` (see Glossary terms); other SLA properties (frequency, availability, …) - are not recorded yet. -- **Lossy mappings are reported.** Besides the info above: off-spec values that were - dropped, `${VAR}` references in quality `query` text, `{object}` placeholders on a table - that is not bound or not found in DataHub, and `physical_urn_overrides` values that are not - dataset URNs, are warnings; team roles defaulted to Technical Owner are infos. -- **ODCS v3.2 coverage is partial.** v3.2 contracts are accepted and validated; only the - mappings below are implemented. `logicalType: vector` maps to an array type (dimensions and - element type are not recorded); `deprecated: true` on a schema object or property emits a - `deprecation` aspect on the logical dataset or field, and an explicit `deprecated: false` - clears it; property - `synonyms` map to the field's AI context synonyms (`status: deprecated` entries are skipped; - `locale` and `source` are dropped). Properties with `semanticType: measure` are aggregates, - not physical columns, so they stay in the logical schema but are left out of the - schema-compliance assertion. Column-level `quality[]` rules on a measure still become field - assertions on the logical dataset; they cannot be evaluated against a physical table. - Deleting a property's `deprecated` key does not undo an earlier run; set - `deprecated: false` instead. On a schema object, deleting the key clears the deprecation - ODCS set when there is a DataHub connection to read it. The contract owns a field's synonyms: they **replace** synonyms set on that field - in DataHub. Only an explicit `synonyms: []` clears them; deleting the key, or a list with no - usable entry, leaves earlier synonyms in place. With a DataHub connection the field's other - AI context (instructions, examples) is kept, and the field is skipped with a warning if that - context cannot be read; without one, the AI context aspect is written as a whole (reported - once as an info), and an empty list writes nothing, so clearing synonyms needs a DataHub - connection. With `strict_validation: false` (the default), off-spec `deprecated`, - `synonyms` or `semanticType` values are dropped and reported as a warning rather than - rejecting the contract; with `strict_validation: true` the contract fails JSON Schema - validation instead. - `context` and `enum` go into descriptions (see [Descriptions](#descriptions)). Accepted but not - yet mapped: schema-object `synonyms`, other `semanticType` uses, and the server fields - `encoding` and `workgroup`. These may land in a - follow-up. -- **Variables are not resolved.** v3.2 `${VAR}` / `${VAR:-default}` references are kept - verbatim. A server `type`, a name-composing server field, an Iceberg `catalogUrl` (or, on a - Glue catalog, `warehouse`), or `physicalName` that contains one leaves the physical binding - unbound, - reported as a warning; use `physical_urn_overrides` to bind it explicitly. A server refused - this way stops the search: later servers are not tried, since the contract may not describe - them. A `${VAR}` in a quality rule's `query` or `implementation` is copied into its - assertion unresolved and reported as a warning, so resolve variables before ingestion (for - example with `envsubst` in CI). Unquoted numbers are read as plain decimals only: a value - such as `0777` or `12:30` keeps its text instead of becoming YAML 1.1 octal or base-60. -- **ODPS documents are not read.** `emit_data_product_association` marks the datasets a - contract governs as output ports of the product the contract names, but the product side - of the Bitol model is not ingested: no ODPS file is parsed, so port names, port versions, - `type`, `sbom`, `inputContracts`, input ports, and management ports are all unavailable, - and a product's own metadata (description, owners, domain) is never written. Port identity - is therefore the dataset, not the ODPS `name`/`version` pair, so "one contract across - several output ports" and "several contracts on one port" remain unrepresentable. A - contract listed under a product's `inputPorts` rather than `outputPorts` cannot be - distinguished from ODCS alone; it would be marked as an output port too. -- **Schema validation depends on the bundled JSON Schemas.** The v3.0.2 / v3.1.0 / v3.2.0 schemas - are vendored with the plugin, so `strict_validation` normally works out of the box. If a - contract declares a supported `apiVersion` for which no validator is available (e.g. a - packaging regression that dropped a schema file), the contract is parsed **without** - schema checking rather than being rejected — `strict_validation` becomes a no-op for - those contracts. Confirm the schemas shipped with your install if you rely on strict - validation as a hard gate. -- **Contract metadata replication**: By default, contract-level ownership and tags are - written to every logical dataset on each run. If you edit these aspects in the DataHub UI, - they will be overwritten on the next ingest. Set `replicate_contract_metadata: false` to - disable replication (useful for one-time enrichment workflows). -- **Mixed-platform `servers[]`**: binding uses the first server whose `type` maps to a - platform; contracts that reference multiple platforms bind to that one only. Use - `physical_urn_overrides` for per-table control. +- **Logical Models are in private beta.** Logical datasets and their assertions are ingested + with `LOGICAL_MODELS_ENABLED` off, just not shown. +- **Variables aren't resolved.** v3.2 `${VAR}` and `${VAR:-default}` are kept as written. One in + a server `type`, a name-composing server field, an Iceberg `catalogUrl` (or `warehouse` on a + Glue catalog) or `physicalName` leaves the entry unbound with a warning, and later servers + aren't tried, since the contract may not describe them. Bind it with + `physical_urn_overrides`. One in a rule's `query` or `implementation` is copied unresolved + and reported, so resolve variables before ingestion (for example with `envsubst` in CI). +- **YAML numbers.** Unquoted numbers are read as plain decimals: `0777` or `12:30` keeps its + text rather than becoming YAML 1.1 octal or base-60. +- **First mappable server only.** A contract naming several platforms binds to the first; + use `physical_urn_overrides` for per-table control. +- **Nested columns.** Field assertions reference columns by dotted property path + (`address.city`), as the logical schema does. Propagation to physical datasets whose + connectors encode nested paths differently depends on DataHub's propagation. +- **Measures.** Column rules on a `semanticType: measure` property still become field + assertions, but can't be evaluated against a physical table. +- **v3.2 coverage is partial.** Not yet mapped: schema-object `synonyms`, other + `semanticType` uses, and server `encoding` and `workgroup`. +- **`deprecated` keys.** Deleting a property's `deprecated` key doesn't undo an earlier run; + set `deprecated: false`. On a schema object, deleting the key clears the deprecation ODCS set, + with a DataHub connection. +- **Synonyms.** The contract replaces a field's synonyms. Only `synonyms: []` clears them; + deleting the key, or a list with no usable entry, keeps earlier ones. With a DataHub + connection the field's other AI context (instructions, examples) is kept, and the field is + skipped with a warning if it can't be read. Without one, the AI context aspect is written + whole (reported once), and an empty list writes nothing, so clearing synonyms needs a + connection. +- **Off-spec v3.2 values.** With `strict_validation: false`, invalid `deprecated`, `synonyms` or + `semanticType` values are dropped with a warning; with `true` the contract fails validation. +- **Links.** `authoritativeDefinitions` URLs DataHub can't store (relative paths like + `../docs/orders.md`, schemes other than http, https, ftp and mailto, or URLs with spaces or + characters such as `|`, `{`, `}`) are skipped, reported once per file. +- **Schema validation needs the bundled schemas.** The v3.0.2, v3.1.0 and v3.2.0 JSON Schemas + ship with the plugin. If one is missing for a supported `apiVersion` (for example after a + packaging regression), the contract is parsed without validation, so `strict_validation` + does nothing for it. +- **ODPS isn't read.** Port names and versions, `type`, `sbom`, `inputContracts`, input and + management ports, and a product's own description, owners and domain are unavailable. A port + is identified by its dataset, so one contract across several ports, or several contracts on + one port, can't be represented, and a contract listed under `inputPorts` is still marked as + an output port. +- **Not mapped:** `price`, `roles`, SLA properties other than `latency` and `retention`, + `relationships` (foreign keys), schema-field `logicalParent` links, `customProperties` (only + `odcs.*` provenance is written), and export back to ODCS. Fields read but not mapped: + property `unique`, `primaryKeyPosition`, `partitioned`, `partitionKeyPosition`, + `criticalDataElement`, `encryptedName` and `physicalName`; schema-object `businessName`; + `contractCreatedTs`; rule `method`, `schedule` and `scheduler`; team `dateIn` and + `replacedByUsername`; server `environment`, `location` and `region`; SLA `valueExt`, + `schedule` and `scheduler`; support `invitationUrl`. These are listed once per file in + `report.spec_fields_ignored`; genuinely unknown fields warn individually. +- **Other reported lossy mappings:** dropped off-spec values, `${VAR}` in rule queries, + `{object}` on an unbound or missing table and invalid `physical_urn_overrides` values are + warnings; owner roles defaulted to Technical Owner are infos. ### Troubleshooting -#### Where do the emitted assertions appear? +#### Where are the assertions? + +On the logical `odcs` dataset's **Quality** tab, which needs `LOGICAL_MODELS_ENABLED`; with +`bind_to_physical_dataset`, on the physical table. Without physical binding, DataHub +propagates expectations to physical tables through `PhysicalInstanceOf`. -On the **logical `odcs` dataset** — open it in the UI (requires `LOGICAL_MODELS_ENABLED`) -and look under its **Quality / Assertions** tab. Assertions are not written to physical -datasets by this source; DataHub propagates expectations to physical instances via the -`PhysicalInstanceOf` relationship. +#### My logical `odcs` dataset doesn't show -#### My contract produced no logicalParent link +Turn on `LOGICAL_MODELS_ENABLED` (see [Prerequisites](#prerequisites)). The metadata is ingested +either way. -Check `report.unmappable_servers` and the per-entry info messages: the contract may -declare no `servers[]`, use a server `type` with no platform mapping (e.g. `kafka`, `s3`), -or be missing the fields needed to qualify a table name (e.g. a postgres server without -`schema`). With a DataHub graph attached, `report.physical_urns_unverified` counts derived -URNs that were skipped because they do not exist in DataHub yet — ingest the physical -platform first, or set `verify_physical_urns_exist: false` to link optimistically. +#### No `logicalParent` link -#### My logical `odcs` dataset doesn't appear in the UI +Check `report.unmappable_servers` and the per-entry infos: no `servers[]`, a server `type` +without a platform (`kafka`, `s3`, …), or missing name fields (a postgres server without +`schema`). With a DataHub connection, `report.physical_urns_unverified` counts tables not in +DataHub yet: ingest the platform first, or set `verify_physical_urns_exist: false`. -Logical Models are in private beta and require the `LOGICAL_MODELS_ENABLED` feature flag -(off by default). Enable it to view logical datasets, their assertions, and their -`logicalParent` links. The metadata is still ingested while the flag is off — it just -isn't displayed. The flag is set on the GMS service (for DataHub Core, the -`LOGICAL_MODELS_ENABLED` environment variable on the `datahub-gms` container; on DataHub -Cloud, ask your administrator to enable it). +#### A rule became a custom assertion -#### My `missingValues`/`mustNotBeBetween`/vendor rule shows up as a Custom Assertion +Expected for anything outside the typed list in [Quality rules](#quality-rule-mapping), such as +`missingValues`, `mustNotBeBetween` or vendor rules. They're kept as written rather than +approximated. -Expected. See [Quality rule mapping](#quality-rule-mapping) for the exact typed-assertion -allowlist and the threshold-representability rules. Anything outside them is preserved -verbatim as `CustomAssertionInfo` rather than approximated. +#### I removed a table but the physical dataset is still there -#### I removed a table from my ODCS file but the physical dataset is still in DataHub +Expected: the physical dataset belongs to its own source. Stale removal soft-deletes the +logical dataset and its assertions. The `logicalParent` on the physical table isn't cleared, +since ODCS never removes what it doesn't own, so it points at the soft-deleted logical dataset +until the table is bound again or you clear it. -That's expected. ODCS owns the logical `odcs` Dataset and the Assertions it emitted; the -physical Dataset belongs to its platform-of-record source (postgres / snowflake / …), and -the `logicalParent` link is a non-destructive enrichment. With `stateful_ingestion` -enabled, removing the `schema[]` entry marks the logical dataset and its assertions -removed on the next ODCS ingest — never the physical dataset. +#### A contract owner shows as an unresolved user -Note the asymmetry: because the physical dataset is intentionally kept out of the ODCS -stateful checkpoint, the `logicalParent` pointer previously written onto it is **not** -cleared when its logical parent is soft-deleted. The physical dataset therefore retains a -`logicalParent` pointing at a now soft-deleted logical dataset until it is next bound or -manually cleaned up. This is deliberate (ODCS must never mutate a physical dataset it does -not own), but it does leave a stale pointer. +The contract's username or email doesn't match how your identity source keys users. Set +`strip_owner_email_domain` or `owner_email_domain` (see [Owners and tags](#owners-and-tags)). -#### My contract owner shows up as an unresolved user +#### My owner edits were reverted -ODCS `team[].username` is a username **or** an email, and DataHub resolves the owner -against whatever identifier your identity source (Okta / Azure AD / SCIM / …) ingests -users under. If the two disagree — the contract says `alice@acme.com` but DataHub knows -the user as `alice`, or vice versa — the ownership reference dangles. Set exactly one of -`strip_owner_email_domain: true` (emails → local part) or `owner_email_domain: acme.com` -(bare usernames → emails) to normalize contract identifiers to your convention; explicit -`urn:li:corpuser:` / `urn:li:corpGroup:` values pass through untouched. When ingesting -through a DataHub graph, owners that don't resolve are flagged in the run report -(`report.owners_unresolved`, one warning per unique owner) — the reference is still -emitted and becomes functional as soon as the user is provisioned. +Contract owners and top-level tags are rewritten each run. Set +`replicate_contract_metadata: false` to stop writing them. -#### I edited owners on a logical dataset and the next ingest reverted them +#### A domain was created that I didn't expect -By default, contract-level ownership replicates on every ingest, so any UI edits are -overwritten. Set `replicate_contract_metadata: false` in the source config to switch to -first-sight-only emission, which preserves UI edits after the initial ingest. The same -setting also governs top-level tags. +The value matched no existing domain by id or name, so ODCS created it. Set `domain` to the +existing domain's id, or `verify_domain_exists: true` to report instead. --- -For the canonical ODCS spec and JSON Schemas, see the -[open-data-contract-standard repository](https://github.com/bitol-io/open-data-contract-standard). -For an audience-friendly entry point and adopter list, see -[bitol.io](https://bitol.io/). +The canonical spec and JSON Schemas are in the +[open-data-contract-standard repository](https://github.com/bitol-io/open-data-contract-standard); +[bitol.io](https://bitol.io/) has an introduction and the adopter list. diff --git a/metadata-ingestion/docs/sources/odcs/odcs_pre.md b/metadata-ingestion/docs/sources/odcs/odcs_pre.md index d07bf72e16196..6092c1ea68c2e 100644 --- a/metadata-ingestion/docs/sources/odcs/odcs_pre.md +++ b/metadata-ingestion/docs/sources/odcs/odcs_pre.md @@ -1,151 +1,69 @@ ### Overview -The `odcs` module ingests Open Data Contract Standard (ODCS) v3.0, v3.1 and v3.2 YAML files from -a path, directory, or glob, and models each contract as a **logical dataset** on the `odcs` -platform: dataset properties, canonical schema metadata, ownership, top-level and -column-level tags, a link to the source document, and the contract's `quality[]` rules as -Assertions attached to the logical dataset. When a `schema[]` entry resolves to a physical -dataset (derived from the contract's typed `servers[]`), the source also emits a -`logicalParent` link from the physical dataset to the logical one. ODCS is governed by -the Linux Foundation under the Bitol project; see [bitol.io](https://bitol.io/) and the -[open-data-contract-standard repository](https://github.com/bitol-io/open-data-contract-standard). - -:::info Looking for the deprecated `*.dhub.dc.yaml` CLI? - -The `datahub datacontract upsert` flow that consumes `*.dhub.dc.yaml` files is unrelated to -this source and is being phased out. To ingest ODCS YAML, use `source.type: odcs` via -`datahub ingest -c ` instead. +The `odcs` module reads ODCS v3.0, v3.1 and v3.2 contract files and emits, per `schema[]` +entry, a dataset with the contract's schema and metadata, its quality rules as assertions, +and a native data contract. By default these go on a logical `odcs` dataset linked to the +physical table; [Choosing a mapping](#choosing-a-mapping) covers the alternative of putting +them on the physical table directly. + +:::info Looking for the `*.dhub.dc.yaml` CLI? + +`datahub datacontract upsert` and its `*.dhub.dc.yaml` files are unrelated to this source and +are being phased out. Ingest ODCS YAML with `source.type: odcs` and `datahub ingest`. ::: ### Prerequisites -**A single ODCS file may describe multiple tables.** Each `schema[]` entry becomes its own -logical `odcs` Dataset. Contract-level owners and top-level tags apply to every logical -dataset by default, and the contract `description` is added to every table's description. See the Concept Mapping table on the platform -Overview above for per-row semantics, and the [Limitations](#limitations) section below for -how to disable replication. - -- ODCS v3.0, v3.1 and v3.2 are supported (any `3.0.x` patch level validates against the same - v3.0.2 JSON Schema; `3.1.0` and `3.2.0` against their own schemas). Contracts whose - `apiVersion` reports v2.x — or any value outside `odcs_versions` — are skipped with a warning. -- **Filter which datasets are ingested with `dataset_pattern`.** The allow/deny regexes - match the composed logical dataset name (`{contract_id}.{schema_name}`, per - `logical_dataset_name_template`). A non-matching `schema[]` entry is skipped along with its - assertions and `logicalParent` link, and recorded under `report.filtered`. Deny takes - precedence over allow. This is orthogonal to `path` globs, which filter by file location - rather than contract content. -- **Assertions attach to the logical dataset by default.** Quality rules and the - schema-compliance assertion are emitted whether or not a physical table exists yet, so - contract-first workflows keep their expectations. Propagation of those expectations onto - bound physical datasets is handled by DataHub via the `PhysicalInstanceOf` relationship — - not by this source. -- **`bind_to_physical_dataset: true` puts them on the physical table.** For each bound - `schema[]` entry whose table exists in DataHub, the quality, freshness and schema - assertions and the data contract target the physical dataset, so results teams post build - one history on the table people use. A contract with exactly one server gets no logical - `odcs` dataset at all; with several servers, the logical dataset and its `logicalParent` - link are still emitted. Nothing else is written onto the physical table: its schema, - description, owners and tags stay as its own source ingested them, and the declared schema - lives in the schema assertion and `rawContract`. Entries that are unbound, or whose table - is not in DataHub, keep the logical mapping; the table is only checked with a DataHub - connection and `verify_physical_urns_exist` on, and is otherwise assumed to exist. Give every quality rule an `id`, since that keeps - an assertion's history when rules are renamed or reordered. This requires - `data_contract_urn: id`, so the contract cannot replace a - hand-written one on the same table, and `emit_logical_parent`, the switch for writing onto - physical tables. When a one-server entry stops having a logical dataset, the - `logicalParent` link an earlier run wrote from the table to it is cleared. -- **A native `dataContract` is emitted per `schema[]` entry** (`emit_data_contract`, default - on) so contracts surface on the **Contract tab**. By default it is written only on the - logical `odcs` dataset — the self-consistent home, since the referenced assertions target - it. That contract renders in the UI only under `LOGICAL_MODELS_ENABLED`, so the table - consumers browse stays empty on the Contract tab until either that flag is enabled or you - opt into `emit_physical_data_contract` (default off), which _also_ writes the contract onto - the bound physical table. The physical write is always non-primary because the contract URN - matches the hand-authored SDK convention exactly — enabling it makes ODCS the owner of that - table's contract — and it requires `emit_logical_parent`. -- **Contract status follows the ODCS `status`.** `active` and `deprecated` contracts are - active in DataHub, since a deprecated contract is still in force until it is retired, and - `proposed` and `draft` ones are pending. A `deprecated` or `retired` contract also marks its - logical `odcs` dataset deprecated. A `retired` contract emits no data contract, and the one - an earlier run emitted is soft-deleted (with a DataHub connection, or by stale removal), - except a dataset-keyed contract on a physical table, which may be hand-written and is only - reported. When a contract becomes active again, the deprecation ODCS set is cleared (with a - DataHub connection); a deprecation set by hand in DataHub is left alone. The ODCS status - itself stays in the `odcs.status` property. A one-server contract bound to its physical - table has no logical dataset to deprecate, so its status is only reported. -- **Contract URNs can follow the ODCS `id`.** By default a contract URN is derived from the - dataset it governs, so with `emit_physical_data_contract` two contracts bound to one table, - or an ODCS contract and a hand-written one, become one entity. Set - `data_contract_urn: id` to key each `schema[]` entry's contract as - `urn:li:dataContract:/`, with `data_contract_urn_prefix: /` in - front if ids are only unique within a repository. Characters DataHub reserves in URNs are - percent-encoded, and so is a `/` inside the id or schema name. Each entry with at least one - assertion then has a single contract that ODCS owns and stale removal manages, holding the - full ODCS YAML in `rawContract`, with any `user:password@` in URLs redacted. It goes on the - physical table with `bind_to_physical_dataset`, or when - `emit_physical_data_contract` is on and the entry is bound, otherwise on the logical - dataset. Switching an existing source to `id` replaces the dataset-keyed contracts on its - logical datasets, which stale removal soft-deletes on the next run. A dataset-keyed - contract an earlier run wrote on a physical table is left in place. -- **Physical binding is derived from the contract itself.** The spec requires - `servers[].type`; the source maps supported types (postgres, mysql, snowflake, bigquery, - redshift, databricks, sqlserver, trino, glue, iceberg) to DataHub platforms and composes fully-qualified - dataset names from the server's own fields (e.g. `database.schema.table`). Use - `server_overrides` to refine `env` / `platform_instance`, or `physical_urn_overrides` - (keyed by contract id, then `schema[]` entry name) for explicit URNs. Binding affects only - the `logicalParent` link. -- **Derived physical URNs are verified by default.** With a DataHub graph available - (datahub-rest sink), a derived URN that does not exist in DataHub is left unbound with a - warning instead of creating a stub dataset (`verify_physical_urns_exist: false` opts out). - With a file sink there is no graph, and links are emitted without verification. -- **Data product output ports are opt-in.** The contract-level `dataProduct` field is free - text, so it is emitted only as the `odcs.dataProduct` custom property by default. Set - `emit_data_product_association: true` to add the dataset each contract governs to that - Data Product as an output port — matching ODPS, where a product lists its contracts under - `outputPorts`. The product must already exist, resolved by id or by display name; the - association is an additive patch that never clears assets added by hand or by another - source. -- **Domain assignment is opt-in.** The contract-level `domain` field is emitted only as the - `odcs.domain` custom property by default. Set `emit_domain_association: true` to set that - DataHub Domain on the contract's logical `odcs` datasets, resolved by id or by name and - created when missing (`verify_domain_exists: true` reports it instead). The contract then - owns that domain: removing `domain` from a contract clears it, including one set by hand. -- **Logical Models are in private beta.** The logical `odcs` datasets this source emits — - and the assertions attached to them — render in the UI only when `LOGICAL_MODELS_ENABLED` - is enabled (off by default). The metadata is ingested either way. The recommended workflow - is: ingest the physical platform source (postgres / snowflake / …), ingest ODCS, and - enable `LOGICAL_MODELS_ENABLED` to see the logical models, their assertions, and their - physical links. -- Files are loaded leniently by default (`strict_validation: false`) so that contracts with - extra or non-conformant fields are accepted with warnings. Spec-valid sections the source - does not read (pricing, relationships, …) are summarized once per file as an - info (`report.spec_fields_ignored`), together with fields the source reads but does not map; - genuinely unknown fields warn individually. See [Limitations](#limitations) for the full - list and the other lossy mappings that are reported. Set `strict_validation: true` to fail on - JSON Schema violations — recommended for multi-tenant or untrusted directories. -- **Stale-metadata removal uses standard stateful ingestion.** Enable it via the - `stateful_ingestion` block (server-side checkpoints; requires a DataHub graph). When you - remove a `schema[]` entry from a contract file, the corresponding logical `odcs` Dataset - and Assertion URNs are marked removed on the next run. Physical datasets and their - `logicalParent` links are **never** marked removed — those are owned by their - platform-of-record source. The `fail_safe_threshold` guard (default 75%) blocks mass - deletions caused by config or naming changes. -- Symlinks are not followed by default (`follow_symlinks: false`). If your directory layout - organises contracts using symlinks, set `follow_symlinks: true` deliberately. The default - is conservative because following symlinks in a shared directory can disclose files - outside the configured root. -- Files larger than `max_input_file_bytes` (default 5 MB) are skipped with a warning before - parsing. -- **Contracts can live in object stores, over HTTP, or in a Git repository.** In addition to - local paths, `path` accepts `s3://` / `gs://` object-store URIs (single file or glob), - `http(s)://` URLs to a single file, and any mix of these in a list. S3 URIs require an - `aws_connection` block and GCS URIs a `gcs_connection` block (both validated up front). - For authenticated `http(s)://` URLs, set an `http_connection` block with either a bearer - `token` or basic-auth `username`/`password` (the two are mutually exclusive), plus an - optional `verify_ssl: false` toggle for trusted hosts with self-signed certificates - (disabling it emits a warning). Public URLs need no `http_connection`. - Set `git_info` to shallow-clone a repository (using an SSH deploy key) and - scan it; each non-URI `path` entry is then resolved relative to the checkout (e.g. - `path: contracts/` or `path: '**/*.odcs.yaml'`). Install the extra dependencies with - `pip install 'acryl-datahub[odcs]'`. +#### Install + +```bash +pip install 'acryl-datahub[odcs]' +``` + +#### Supported contracts + +- `apiVersion` 3.0.x (validated against the v3.0.2 JSON Schema), 3.1.0 and 3.2.0. Anything + else, including v2.x, is skipped with a warning. `odcs_versions` sets the accepted list. +- One file can describe several tables: each `schema[]` entry becomes its own dataset. + Contract-level owners, top-level tags and the contract description apply to each of them. +- v3.2 support is partial: v3.2 contracts are accepted and validated, and only the + additions in the Concept Mapping table are mapped. + +#### Where contracts are read from + +`path` takes one location or a list mixing any of these: + +| Location | Example | Needs | +| --------------------------- | -------------------------------------- | -------------------------------------------------------------------------------- | +| Local file, directory, glob | `./contracts/`, `'**/*.odcs.yaml'` | — | +| S3 | `s3://my-bucket/contracts/*.odcs.yaml` | `aws_connection` | +| GCS | `gs://my-bucket/contracts/*.odcs.yaml` | `gcs_connection` (HMAC credentials) | +| HTTP(S), single file | `https://example.com/orders.odcs.yaml` | `http_connection` for auth: a bearer `token` or `username`/`password`, not both | +| Git repository | `git_info` + `path: contracts/` | An SSH deploy key. Non-URI `path` entries resolve relative to the shallow clone. | + +Missing connection blocks are caught when the recipe is validated. `http_connection` also +takes `verify_ssl: false` for trusted hosts with self-signed certificates; turning it off is +reported as a warning. Directories are scanned for `file_extensions` (`.yaml`, `.yml`, +`.odcs.yaml`, `.odcs.yml`). + +#### File safety + +| Setting | Default | Effect | +| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| `max_input_file_bytes` | 5 MB | Larger files are skipped with a warning before parsing. | +| `follow_symlinks` | `false` | Symlinks are not followed, since that can expose files outside the root in a shared directory. When on, targets must still stay inside the root. | +| `strict_validation` | `false` | Files failing JSON Schema validation are ingested with warnings. Set `true` to skip them; recommended for untrusted input. | + +#### Ingest physical tables first + +Physical tables are found from the contract's `servers[]`. With a DataHub connection +(datahub-rest sink) and `verify_physical_urns_exist` on (the default), a table that isn't in +DataHub yet is left unbound with a warning instead of being created as an empty stub. Run the +physical platform's source (Snowflake, Postgres, …) before this one. + +#### Enable Logical Models to see logical datasets + +Logical `odcs` datasets show in the UI only with `LOGICAL_MODELS_ENABLED` on. On DataHub +Core, set it as an environment variable on the `datahub-gms` container; on DataHub Cloud, ask +your administrator. The metadata is ingested either way. diff --git a/metadata-ingestion/docs/sources/odcs/odcs_recipe.yml b/metadata-ingestion/docs/sources/odcs/odcs_recipe.yml index 9b29f18efa1d7..3c7525ab582cd 100644 --- a/metadata-ingestion/docs/sources/odcs/odcs_recipe.yml +++ b/metadata-ingestion/docs/sources/odcs/odcs_recipe.yml @@ -48,6 +48,19 @@ source: # orders: "urn:li:dataset:(urn:li:dataPlatform:snowflake,prod.sales.orders,PROD)" # legacy_orders: "" + # Put assertions and contracts on the physical table instead of a logical + # dataset (needs id-keyed contract urns): + # data_contract_urn: id + # data_contract_urn_prefix: acme/data-contracts + # bind_to_physical_dataset: true + + # Your own glossary terms for classifications and retention SLAs: + # classification_glossary_term_mapping: + # confidential: urn:li:glossaryTerm:Tier.Confidential + # retention_glossary_terms: + # - min_days: 365 + # term: urn:li:glossaryTerm:Retention.1Year + # Standard stateful ingestion: removing a schema[] entry from a contract # marks its logical dataset + assertions removed on the next run. Physical # datasets are never touched. @@ -59,7 +72,7 @@ source: # # verify_physical_urns_exist: true # with a DataHub graph: skip logicalParent links whose derived URN doesn't exist # lowercase_physical_urns: true # lowercase composed physical names for platforms that lowercase by default (snowflake) - # emit_assertions: true # assertions from quality[] rules and latency SLAs, attached to the logical dataset + # emit_assertions: true # assertions from quality[] rules and latency SLAs # emit_schema_assertion: true # one DATA_SCHEMA assertion per schema[] entry pinning the contract's schema # schema_assertion_compatibility: SUPERSET # or EXACT_MATCH / SUBSET # emit_logical_parent: true # the physical->logical PhysicalInstanceOf link @@ -72,7 +85,7 @@ source: # still emitted — they resolve once the user is provisioned. # strip_owner_email_domain: false # alice@acme.com -> corpuser alice # owner_email_domain: acme.com # alice -> corpuser alice@acme.com - # odcs_versions: ["3.0.0", "3.0.1", "3.0.2", "3.1.0"] + # odcs_versions: ["3.0.0", "3.0.1", "3.0.2", "3.1.0", "3.2.0"] # logical_dataset_name_template: "{contract_id}.{schema_name}" # logical odcs dataset URN name # # Filter which logical datasets are ingested by their composed name @@ -86,9 +99,8 @@ source: # file_extensions: [".yaml", ".yml", ".odcs.yaml", ".odcs.yml"] # max_input_file_bytes: 5242880 # 5 MB; larger files are skipped with a warning # - # Replicate contract-level ownership/tags to every logical dataset on each - # ingest. Set false to emit these aspects only at first sight, which - # preserves manual UI edits but means contract changes don't propagate. + # Write contract-level owners and top-level tags to every logical dataset on + # each ingest. Set false to stop writing them, so edits made in DataHub stay. # replicate_contract_metadata: true # Default sink is datahub-rest and doesn't need to be configured.