Area: Observability
Sub-Area: Schema Management
Applies to: OSS + Cloud
Issue
Schema changes (column additions, deletions, type changes) are not being tracked or communicated effectively, leading to downstream pipeline failures. You need a way to see schema changes, review schema history, and get alerts.
You Might Be Asking
- How does DataHub track schema changes?
- Can I get alerts for schema changes?
- How do I see schema version history?
Cause
DataHub tracks schema history without any recipe setting. A dataset shows schema history once it has more than one schemaMetadata version. Stateful ingestion plays no part in this. It only soft-deletes entities that were in the last successful run of the same pipeline but are missing from the current run.
Alerts are not on by default. Per-asset alerts go to people who subscribe to the asset. Email is enabled by default as a channel, but Slack and Teams need their apps installed first. Self-hosted DataHub (OSS) has no subscriptions or notifications, so it has no built-in alerts.
Solution
1. Check that ingestion emits the schema
For Snowflake, include_tables, include_views and include_technical_schema all default to true (acryl-datahub 1.7.0.20). You don't need to change your recipe to get schema history. Other sources may differ, so check the source's page.
2. View schema history in the UI (OSS and Cloud)
Open the dataset's Schema tab. Use the version selector to see older versions. Use the Audit view to see when each field last changed. Viewing schema history needs the View Entity Page privilege or any DataHub role. See Schema History.
3. Query schema history through the API
Schema history is computed by the Timeline API. Use these GraphQL queries:
-
getSchemaVersionList(input: { datasetUrn: "..." })returnslatestVersion,versionandsemanticVersionList. -
getSchemaBlame(input: { datasetUrn: "...", version: "..." })returnsversionandschemaFieldBlameList, withfieldPathandschemaFieldChangefor each field. -
getTimeline(input: { urn: "...", changeCategories: [TECHNICAL_SCHEMA] })returnsGetTimelineResult. You must select sub-fields ofchangeTransactions, for example:
query {
getTimeline(input: { urn: "YOUR_URN", changeCategories: [TECHNICAL_SCHEMA] }) {
changeTransactions {
timestampMillis
lastSemanticVersion
changeType
actor
changes {
category
operation
modifier
description
}
}
}
}
The getTimeline field list above is verified for DataHub Cloud v2.4.4. The getTimeline mutation signature also exists in OSS v1.9.0.
You can also call the Timeline REST API:
/openapi/v2/timeline/v1/{url-encoded urn}?categories=TECHNICAL_SCHEMA&start=<ms>&end=<ms>
Each change has a semVerChange of NONE, PATCH, MINOR, MAJOR or EXCEPTIONAL. Each change transaction gets a computed semantic version based on its most significant change. For schemas, a backwards incompatible change, such as a native datatype change, bumps the version to a new major version. See Timeline API.
From the CLI:
datahub timeline --urn <urn> -c technical_schema --start 7daysago
The -c option is required. You can repeat it. Add --raw for raw output.
4. Get alerts on schema changes
DataHub Cloud:
- Subscribe to the dataset and select Schema change events. Notifications go to Slack, Microsoft Teams or email. See Subscriptions and notifications.
- Or create a Schema Assertion. Schema Assertions are Cloud only. They run whenever a schema change is detected in the ingested schema. The condition types are Contains and Exact Match. In the UI, go to the dataset, open the Quality tab, click + Create Assertion, then choose Schema. You need the Edit Assertions and Edit Monitors privileges. Entity owners get them through the Asset Owners - Metadata Policy by default. See Schema Assertions.
Through the API, use upsertDatasetSchemaAssertionMonitor(assertionUrn, input). The input requires entityUrn, assertion (with compatibility and fields), mode and evaluationSchedule: { cron: "...", timezone: "..." }. The evaluationSchedule is required even though the docs example omits it. The supported compatibility types are EXACT_MATCH and SUPERSET (Contains).
Self-hosted DataHub (OSS): Schema field additions and removals are Entity Change Events with category TECHNICAL_SCHEMA and operation ADD or REMOVE. The parameters are fieldUrn, fieldPath and nullable. Write a custom Action that handles these events. Subclass Action, implement create(config_dict, ctx) and act(event: EventEnvelope), and reference it as type: "module.path:ClassName". DataHub Actions has no built-in schema_change_alert action. See Entity Change Event and Actions concepts.
DataHub Cloud with external tools: Use the Entity Events API, or a DataHub Actions pipeline with source type datahub-cloud. The token's user needs the Get Platform Events privilege. See Entity Events API and datahub-cloud event source.
5. Document breaking changes
Use a patch, not a full aspect write. DataHub's patch APIs make partial updates without overwriting unrelated fields on the same entity. See Emitting patch updates. DatasetPatchBuilder from datahub.specific.dataset offers add_custom_property(key, value) and set_description(description, editable=True). With editable=True, the description goes to editableDatasetProperties.
To send the change, create DatahubRestEmitter(gms_server=..., token=...) from datahub.emitter.rest_emitter. The builder's build() returns a list of MCPs. Emit each one:
for mcp in patch_builder.build():
emitter.emit_mcp(mcp)
emitter.emit(mcp) also works. emit_mcp takes one MCP argument. It has no entity_urn, aspect_name or aspect parameters.