Skip to content

refactor(ingest): send MCEs as MCPs from the REST emitter and file source - #21356

Open
aviraj-gour wants to merge 20 commits into
masterfrom
refactor/mce-sdk-phase2
Open

aviraj-gour wants to merge 20 commits into
masterfrom
refactor/mce-sdk-phase2

Conversation

@aviraj-gour

@aviraj-gour aviraj-gour commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Connectors emit MCPs only. This PR turns the last two SDK entry points that still pass MetadataChangeEvents on into MCP-only paths, deprecates MCE input there, and clears out dead MCE code in tests, examples and docs. One commit per change, so it reviews best commit by commit.

 file source reads a record
-  MCE  -> MetadataWorkUnit(mce=)            # transformers/sinks see MCEs
+  MCE  -> warn once per file
+       -> one MCP work unit per aspect      # transformers/sinks see MCPs only
+  MCE with no aspects -> report warning, skipped
+  MCE that fails conversion -> report failure for that record, file keeps going
   MCP  -> MetadataWorkUnit(mcp=)

 DatahubRestEmitter.emit(mce) / emit_mce(mce)
-  POST /entities?action=ingest             # whole MCE, ignores emit_mode
+  DataHubDeprecationWarning
+  mcps_from_mce(mce) -> emit_mcps(mcps, emit_mode)   # one ingestProposalBatch

 datahub-rest sink, SYNC/ASYNC, receives an MCE
-  emitter.emit(mce)
+  mcps_from_mce(mce) -> emitter.emit_mcps(mcps, emit_mode)   # one batch, no SDK warning
+  MCE with no aspects -> report warning, skipped
Commit Change
refactor(ingest): describe MCP output in comments and check metadata-file comments and CLI wording that still said "MCE" for MCP output
refactor(ingest/sql): drop SqlWorkUnit from return type hints type hints only
test(ingest): drop dead MCE branches from connector tests MCE branches and MCE-shaped ignore_paths that no golden reaches; the lookml lineage check was vacuous and now reads MCP upstreamLineage
refactor(ingest): store the bootstrap sample data as MCPs bootstrap_mce.json as 220 MCPs
docs(ingest): teach MCPs in examples and docs REST lineage example, custom transformer example, adding-source.md, file-source JSON samples, sphinx builder page
fix(ingest/rest): send MCEs as MCPs from the REST emitter REST twin of #20962; the datahub-rest sink expands MCEs itself in SYNC/ASYNC (ASYNC_BATCH already did), so recipe users get no warning
fix(ingest/file): read MCEs as MCPs in the file source MCE files still load; one report warning per file
fix(ingest/file): report MCEs without aspects and correct MCE docs an MCE with no aspects is reported instead of yielding an empty work unit (a warning since the review fixes below); MCE wording in docs
fix(ingest): send an MCE's aspects as one batch from the REST emitter emit(mce)/emit_mce send all aspects in one ingestProposalBatch request so GMS stamps them as one change; an oversized MCE is split across requests by the existing batch chunking
fix(ingest): show the reason in check metadata-file failures datahub check metadata-file prints the failure message, not only its context
fix(ingest/file): apply the aspect filter to MCE-derived MCPs the aspect option filters the MCPs made from an MCE like native MCP records
fix(ingest): skip MCEs without aspects and batch MCEs in the REST sink review fixes: an MCE with no aspects is a report warning and is skipped; each MCP from an MCE gets its own work unit id; the datahub-rest sink sends an MCE as one emit_mcps batch in SYNC/ASYNC; check metadata-file lists report warnings under its summary
fix(ingest/file): report an MCE that fails conversion and keep reading an MCE that mcps_from_mce cannot convert (e.g. an invalid URN) is one report failure for that record instead of stopping the file; docs for the per-aspect timeline of MCE files
refactor(ingest): share the MCE deprecation warning across emitters MCE_DEPRECATION_MESSAGE and the once-per-process warn_mce_deprecated() move to generic_emitter, so the REST and Kafka emitters log it once between them
docs(ingest): remove lineage example that duplicates lineage_emitter_mcpw_rest.py deletes lineage_emitter_rest.py, which after the docs commit was the same as lineage_emitter_mcpw_rest.py
fix(ingest/file): title MCE report entries and drop --unpack-mces plumbing titles on the file source's MCE report entries; check metadata-file no longer passes unpack_mces_into_mcps to the extractor
fix(ingest): report empty MCEs in the REST sink, deprecate --unpack-mces, move mcps_from_mce to emitter.mcp the datahub-rest sink reports an MCE with no aspects as a warning and skips it in every mode; --unpack-mces is marked deprecated; mcps_from_mce moves to datahub.emitter.mcp, which drops the deferred imports in the Kafka emitter and MetadataWorkUnit
fix(ingest): name the URN of skipped empty MCEs and import mcps_from_mce from emitter.mcp the file source's empty-MCE warning names the URN; the file source and REST sink import mcps_from_mce from its new home; tests for the REST emitter's empty-MCE path and for --unpack-mces

mcps_from_mce stays as the migration path. It now lives in datahub.emitter.mcp, which imports no ingestion code; datahub.emitter.mcp_builder re-exports it, so existing imports keep working. datahub check metadata-file --unpack-mces has no effect and prints a deprecation notice. Builders, MetadataWorkUnit(mce=) and the MCE transformer branches are untouched here.

Evidence

  • Before: the file source yielded MetadataWorkUnit(mce=...) for MCE files; emit(mce) posted to /entities?action=ingest.
    After:
    • test_file_source_converts_mces_to_mcps: work units equal mcps_from_mce of each MCE, exactly one report warning naming only the MCE file. Fails without the file source change.
    • test_file_source_skips_mce_without_aspects: no work units, no failures, one warning naming the record and its URN, and check metadata-file prints it.
    • test_file_source_reports_unconvertible_mce_and_continues: an MCE with an invalid URN is one failure and the next MCE is still read. Fails without the fix (the source raised AssertionError).
    • test_serde_to_json on MCE fixtures now checks with golden_mces_as_mcps + fail_on_output_mces.
    • test_rest_emitter.py (+6): emit(mce) makes one ingestProposalBatch request, or one OpenAPI request with openapi_ingestion on, with the aspects in order and systemMetadata carried over, and an explicit emit_mode wins over the default; deprecated emit_mce uses the default emit mode; a failure reaches the callback and raises; the warning logs once per process; an MCE with no aspects sends no request. test_rest_sink.py: the sink sends an MCE as one emit_mcps batch with the resolved emit_mode, and reports and skips an MCE with no aspects in both the single and batch paths.
    • test_check_metadata_file_accepts_deprecated_unpack_mces: check metadata-file --unpack-mces still runs.
    • lookml lineage test fails when upstreamLineage is stripped from the output.
    • remote_file_golden.json rewritten as MCPs; the same recipe run locally on mce_list.json produces identical JSON.
  • Local: targeted unit tests for the touched areas pass (the unrelated TestSetupRecording failures come from the recording extra not being installed); ruff and mypy clean on the changed files.
  • Needs CI (Docker): test_remote.py, test_flink.py, test_s3.py, test_informix.py, test_snowplow.py::test_snowplow_iglu_autodiscovery.

Merge Danger

Door: two-way

Revert restores the MCE paths; no stored data changes shape.

Blast Radius: SDK users

  • Code calling DatahubRestEmitter/DataHubGraph.emit(mce) or emit_mce now gets a deprecation warning and sends the MCE's aspects as one ingestProposalBatch request that follows emit_mode (default SYNC_PRIMARY) instead of always writing synchronously; an empty MCE is not sent.
  • Recipes whose source hands MCEs to the datahub-rest sink in SYNC/ASYNC mode send each MCE as one MCP batch, and skip an MCE with no aspects with a report warning; if GMS rejects one aspect, others from the same MCE may already be stored.
  • Recipes with the file source over MCE files: custom transformers that handle only MCEs stop seeing those records; a file sink downstream writes MCPs; with the datahub-rest sink in SYNC/ASYNC mode each aspect is its own request, so the timeline shows one change per aspect instead of one per MCE; an MCE with no aspects is skipped with a warning; an MCE that fails conversion is one failed record and the rest of the file is still read.
  • These are in docs/how/breaking-changes.md (Deprecations and Other notable changes).

🤖 Generated with Claude Code

@github-actions github-actions Bot added ingestion PR or Issue related to the ingestion of metadata docs Issues and Improvements to docs labels Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
32014 3 32011 132
View the top 3 failed test(s) by shortest run time
tests.integration.airbyte.test_airbyte::test_airbyte_platform_instance_urns
Stack Traces | 0.292s run time
Metadata files differ (use `pytest --update-golden-files` to update):
Urn removed, urn:li:dataJob:(urn:li:dataFlow:(airbyte,custom-platform.66666666-6666-6666-6666-666666666666,PROD),66666666-6666-6666-6666-666666666666_customers)
Urn removed, urn:li:dataJob:(urn:li:dataFlow:(airbyte,custom-platform.66666666-6666-6666-6666-666666666666,PROD),66666666-6666-6666-6666-666666666666_orders)
Urn removed, urn:li:dataset:(urn:li:dataPlatform:postgres,test.source_db.orders,PROD)
Urn removed, urn:li:dataFlow:(airbyte,custom-platform.66666666-6666-6666-6666-666666666666,PROD)
Urn removed, urn:li:dataset:(urn:li:dataPlatform:postgres,test.source_db.customers,PROD)
tests.integration.airbyte.test_airbyte::test_airbyte_schema_filter
Stack Traces | 18.6s run time
Metadata files differ (use `pytest --update-golden-files` to update):
Urn removed, urn:li:dataset:(urn:li:dataPlatform:postgres,test.source_db.orders,PROD)
Urn removed, urn:li:dataFlow:(airbyte,66666666-6666-6666-6666-666666666666,PROD)
Urn removed, urn:li:dataJob:(urn:li:dataFlow:(airbyte,66666666-6666-6666-6666-666666666666,PROD),66666666-6666-6666-6666-666666666666_customers)
Urn removed, urn:li:dataset:(urn:li:dataPlatform:postgres,test.source_db.customers,PROD)
Urn removed, urn:li:dataJob:(urn:li:dataFlow:(airbyte,66666666-6666-6666-6666-666666666666,PROD),66666666-6666-6666-6666-666666666666_orders)
tests.integration.airbyte.test_airbyte::test_airbyte_ingest
Stack Traces | 570s run time
Metadata files differ (use `pytest --update-golden-files` to update):
Urn removed, urn:li:dataFlow:(airbyte,test-instance.66666666-6666-6666-6666-666666666666,PROD)
Urn removed, urn:li:dataset:(urn:li:dataPlatform:postgres,test.source_db.orders,PROD)
Urn removed, urn:li:dataJob:(urn:li:dataFlow:(airbyte,test-instance.66666666-6666-6666-6666-666666666666,PROD),66666666-6666-6666-6666-666666666666_orders)
Urn removed, urn:li:dataJob:(urn:li:dataFlow:(airbyte,test-instance.66666666-6666-6666-6666-666666666666,PROD),66666666-6666-6666-6666-666666666666_customers)
Urn removed, urn:li:dataset:(urn:li:dataPlatform:postgres,test.source_db.customers,PROD)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: active. Only the selection below runs for the pytest smoke tests on this PR (applied: smart).

  • Selection: smart: tests for the tagged features, plus always-run modules, this PR's changed tests, and the plumbing sample if the PR changes the pytest harness
  • Size: 130 of 846 tests in 1 batch, predicted longest batch ~4 min
  • Tags: change-type: docs; compound: ingestion:connector; entity-scope: dataset; feature-dev: mce-mcl-pipeline, schema-translation; feature-user: documentation, ingestion, lineage, schema-metadata; technical-layer: cli, kafka-events, restli
  • Confidence: MEDIUM (61 changed files)
  • Classifier reasoning: Changes deprecate MCE emission by converting MCEs to MCPs in emitters, sinks, and file source, touching many ingestion connectors and CLI, plus docs-only edits.

Medium confidence: a wrong tag means tests are skipped, so check the tags above against what this PR touches.

Selected scopes (36 files or classes, 130 tests)
  • tests/e2e/actions/doc_propagation/test_propagation.py
  • tests/e2e/assertions/dbt_test_results_test.py
  • tests/e2e/audit_events/audit_events_test.py
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/cli/ingest_cmd/test_timeseries_rollback.py
  • tests/e2e/cli/migrate_cmd/test_migrate_instance2instance_smoke.py
  • tests/e2e/cli/migrate_cmd/test_migrate_scenarios_smoke.py
  • tests/e2e/delete/delete_test.py
  • tests/e2e/entity_versioning/test_versioning_ingest.py
  • tests/e2e/frontend/test_static_asset_encodings.py
  • tests/e2e/institutional_memory/institutional_memory_test.py
  • tests/e2e/knowledge/document_change_history_test.py
  • tests/e2e/knowledge/document_search_filter_test.py
  • tests/e2e/knowledge/test_document_crud.py::TestDocumentCrudAndMutations
  • tests/e2e/knowledge/test_document_hierarchy_settings.py::TestDocumentHierarchyAndSettings
  • tests/e2e/knowledge/test_document_search_history.py::TestDocumentSearchAndHistory
  • tests/e2e/knowledge/test_okf_reimport.py
  • tests/e2e/lineage/test_datajob_lineage_patch.py
  • tests/e2e/lineage/test_lineage.py
  • tests/e2e/lineage/test_lineage_counts.py
  • tests/e2e/lineage/test_lineage_sdk.py
  • tests/e2e/managed_ingestion/managed_ingestion_test.py
  • tests/e2e/mcp/mcp_test.py
  • tests/e2e/odcs/test_odcs_ingestion.py
  • tests/e2e/openapi/v3/test_scroll_lineage.py
  • tests/e2e/pgqueue/test_messaging_operations.py
  • tests/e2e/read_only/test_ingestion_list.py
  • tests/e2e/read_only/test_lineage_apis.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/schema_fields/test_schemafields.py
  • tests/e2e/search/test_lineage_search_index_fields.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection
  • tests/e2e/test_kafka_default_sink.py
  • tests/e2e/test_rapid.py
  • tests/e2e/test_stateful_ingestion.py
  • tests/e2e/timeline/timeline_test.py

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

commit 3922837 · workflow run

@datahub-connector-tests

datahub-connector-tests Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Connector Tests Results

All connector tests passed for commit d060dc4

View full test logs →

To skip connector tests, add the skip-connector-tests label (org members only).

Autogenerated by the connector-tests CI pipeline.

@cursor

cursor Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
MetadataChangeEvents (MCEs) are deprecated on the remaining ingestion paths: the file source, REST/Kafka emitters, and datahub-rest sink now convert each MCE into one MetadataChangeProposal (MCP) per aspect, so pipelines, transformers, and sinks see MCPs only. Shared mcps_from_mce lives in datahub.emitter.mcp; emitters log a once-per-process deprecation via generic_emitter.

REST emission no longer posts whole snapshots to /entities?action=ingest; MCEs go through ingestProposalBatch (or OpenAPI) with the caller’s emit_mode, so writes are per-aspect and no longer all-or-nothing. Empty or unconvertible MCEs are skipped or reported without stopping the rest of a file.

Docs, examples, and goldens switch file-based recipes and samples from snapshot JSON to MCP records; datahub check metadata-file counts MCPs and --unpack-mces is deprecated. SQL connector type hints drop SqlWorkUnit in favor of MetadataWorkUnit only; some legacy MCE examples and tests are removed or tightened.

Reviewed by Cursor Bugbot for commit 3922837. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9b8fa74. Configure here.

@naeemdh naeemdh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments inline. One behavior change (empty-aspect MCEs in the file source) looks worth fixing or documenting before merge; the rest are minor.

mce.proposedSnapshot.urn,
response.status_code,
)
_warn_mce_deprecated()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: an MCE now gets the deprecation twice: as a DataHubDeprecationWarning (from emit() or the @deprecated on emit_mce) and again as this log line with the same text. One of the two is probably enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept both on purpose. DataHubDeprecationWarning subclasses DeprecationWarning, which Python hides unless the caller is __main__, so library callers like the Airflow hook would get no notice without the log line. It's logged once per process, the same as DatahubKafkaEmitter.

@naeemdh naeemdh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: one thing worth settling before merge (the file source splitting an MCE into per-aspect writes, see file.py), plus three smaller notes. The emitter batching, conversion-failure handling, aspect filter and bootstrap rewrite look sound.

self.config.aspect is None
or mcp.aspectName == self.config.aspect
):
yield MetadataWorkUnit(f"{id}-{mcp.aspectName}", mcp=mcp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One work unit per MCP means file → datahub-rest in SYNC/ASYNC now writes each aspect of an MCE as its own request. The timeline shows one change per aspect, and the MCE is no longer all-or-nothing. In ASYNC_BATCH mode the aspects can also fall into different batches.

The breaking-changes entry covers this, but timeline_test.py was moved from ingest_file_via_rest to graph_client.emit_mcps. That hides the behaviour change and drops the only e2e coverage of the file → rest path for these files.

Could we keep an MCE's MCPs together, e.g. one record per MCE that the sink sends with a single emit_mcps? If per-aspect is the intended trade-off, could we keep one smoke test on ingest_file_via_rest that asserts the per-aspect timeline?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per-aspect is the intended trade-off. The sink can already send an MCE as one emit_mcps batch, but only if the MCE itself reaches it, which is the old file-source behaviour this PR removes so that transformers and sinks see MCPs only. Keeping that grouping on MCPs would need a new record type that carries several MCPs, and I don't think that's worth it for an input we're deprecating. The file → rest path for MCE files is still covered end to end: data.json (loaded in conftest.py), cli_test_data.json, graph_data.json and schema_field_side_effect_data.json all go through ingest_file_via_rest. The timeline test moved to emit_mcps because it asserts how GMS diffs aspects, not how the file source groups them. I'd rather not add a smoke test that pins the per-aspect timeline of a deprecated path; the change is in breaking-changes.md.

self.emitter.emit(record, emit_mode=emit_mode)
if isinstance(record, MetadataChangeEvent):
# Not emitter.emit(): that logs an MCE deprecation warning recipe users cannot act on.
self.emitter.emit_mcps(list(mcps_from_mce(record)), emit_mode=emit_mode)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things here:

  1. In sink ASYNC mode, MCE writes now follow _gms_emit_mode and become async in GMS, so a validation or DB error no longer shows in the run report. Before, /entities?action=ingest always wrote synchronously.
  2. An MCE with no aspects calls emit_mcps([]) and counts as a success with no warning. DatahubRestEmitter._emit_mce logs a warning for the same input. Worth a self.report.warning here so the record doesn't vanish silently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) That's the same behaviour sink ASYNC mode already has for MCPs, and it's in breaking-changes.md (REST emitter entry). (2) Fixed: the sink now logs and reports a warning for an MCE with no aspects and skips it, in every mode including ASYNC_BATCH.

is_flag=True,
help="Deprecated and has no effect: MCEs are always converted into MCPs.",
)
def metadata_file(json_file: str, rewrite: bool, unpack_mces: bool) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: --unpack-mces is now accepted and silently ignored. Could we print a short deprecation notice when it's passed, or mark the option hidden=True? Scripts that relied on the old --rewrite keeping the MCE format would then see why their output changed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked it deprecated=True, so click prints a notice when it's passed and the help shows "(DEPRECATED)". Scripts that relied on --rewrite keeping MCEs never passed this flag, so the breaking-changes entry is what covers them.

def _emit_mce(self, mce: MetadataChangeEvent, emit_mode: EmitMode) -> None:
"""Sends the MCE's aspects in one batch, which GMS stamps as one change unless an oversized MCE is split across requests."""
# Deferred to break the cycle mcp_builder -> ingestion.api.workunit -> ingestion.api.common -> graph.client -> rest_emitter.
from datahub.emitter.mcp_builder import mcps_from_mce

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: metadata-ingestion/AGENTS.md says imports always go at the top of the file. I see the cycle comment. mcps_from_mce only needs schema classes, so moving it (or a core helper) to a leaf module would let both rest_emitter and kafka_emitter import it at the top. Fine as a follow-up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in this PR: mcps_from_mce now lives in emitter/mcp.py and is imported at the top of both emitters and workunit.py; mcp_builder re-exports it.

@naeemdh naeemdh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall; three small non-blocking nits inline.

) -> None:
# TODO: Add timing metrics
self.emitter.emit(record, emit_mode=emit_mode)
if isinstance(record, MetadataChangeEvent):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: when an MCE has no aspects, this branch reports a warning and returns normally, so _write_done_callback sees no exception and still calls report_record_written / on_success. With 10 MCEs of which 2 are empty, the report shows 2 skip warnings and 10 records written. Could the skip be tracked (e.g. a skipped counter, or a sentinel the done-callback checks) so total_records_written matches what was sent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d060dc4: write_record_async now handles an MCE with no aspects before submitting it, in every mode. It logs and reports the warning, then acknowledges the record with on_success, as the Kafka sink does. Since it is never submitted, the done-callback does not run for it and total_records_written only counts what was sent.

yield MetadataWorkUnit(id, mcp=obj)
else:
yield MetadataWorkUnit(id, mcp_raw=obj)
elif not obj.proposedSnapshot.aspects:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this empty-MCE branch comes before the one that sets warned_mce, so a file whose MCEs all have no aspects never gets the "MetadataChangeEvents are deprecated" warning. Moving the once-per-file deprecation warning ahead of the empty-aspects check would cover any MCE in the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d547df: the once-per-file deprecation warning now comes before the empty-aspects check, so a file whose MCEs all have no aspects gets it too.

report = mce_source.get_report()
summary = f"{report.events_produced} MCPs found - all valid"
for warning in report.warnings:
summary += f"\nWarning: {warning.message}: {warning.context}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: StructuredLogEntry.context is a LossyList[str], so this prints e.g. Warning: ...: ['mce.json'] with brackets and quotes. Same for the failure line above (line 21). ', '.join(warning.context) would print the plain path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d547df: both the warning and the failure line now print ', '.join(...context), so the output shows the plain path.

@naeemdh naeemdh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Only the three non-blocking nits above.

…file

Connectors now emit MCPs, so comments that said MCE were stale.
`datahub check metadata-file` counts every record the file source
produced, MCE or MCP, so it now reports "records found".
SQL sources no longer construct SqlWorkUnit, so their work unit
iterables are plain MetadataWorkUnit. The class itself stays for custom
sources that import or subclass it.
Every connector now emits MCPs, so the MCE branches in these test helpers
never run and the MCE-shaped ignore_paths match nothing in the MCP-only
goldens. The lookml hive check only inspected MCE snapshots, so it
asserted nothing; it now reads the upstreamLineage MCPs and requires at
least one.
Convert the 82 MCEs in bootstrap_mce.json to one MCP per aspect with
expand_mces; the 21 records that were already MCPs are unchanged. The
file holds the same (urn, aspect, systemMetadata) values in the same
order, so loading it stores the same aspects; the run report now counts
one record per aspect.

Also delete an Azure AD golden no test reads and an example recipe that
pointed at a file that does not exist.
The REST lineage example emits an UpstreamLineage MCP like its Kafka
twin, the custom transformer PATCH example is a transform_aspect, and the
file-ingestion JSON samples are MCPs. adding-source points new sources at
MetadataChangeProposalWrapper and the SDK entity classes.
DataHubRestEmitter.emit() and emit_mce() now convert a
MetadataChangeEvent with mcps_from_mce and emit each aspect through
emit_mcp, so MCE input uses ingestProposal (or OpenAPI) and honours
emit_mode instead of posting to /entities?action=ingest. Both warn with
DataHubDeprecationWarning, and the deprecation is logged once per
process. An MCE with no aspects emits nothing and logs a warning.

The datahub-rest sink's SYNC/ASYNC path expands MCEs itself, like its
ASYNC_BATCH path and the Kafka sink, so recipe users get no warning
about emitter code they do not own.

This mirrors the Kafka emitter change in #20962.
The file source turns each MetadataChangeEvent it reads into one MCP per
aspect and reports one deprecation warning per file, so transformers and
sinks only receive MCPs. Reading MCEs will be removed in a future release.
The file source reports an MCE with no aspects as a failure instead of
dropping it, as the extractor did before MCEs were split in the source.
Mark --unpack-mces as having no effect, complete the breaking-changes
entries (PR links, check metadata-file, emit mode default, ASYNC sink
errors), fix stale comments and docs, and tighten the file-source and
REST emitter tests.
The REST emitter sent each aspect of an MCE as its own request, so GMS
stamped them at different times and the timeline showed one change per
aspect instead of one per MCE. emit(mce) and emit_mce now send the MCE's
MCPs in one emit_mcps batch, as the old /entities?action=ingest call did.

Inside an ingestion pipeline MCEs stay individual MCPs and the sink mode
decides batching; breaking-changes.md notes the per-aspect timeline in the
sink's SYNC and ASYNC modes.

The timeline smoke test now uses MCP fixtures and writes each dataset
version in one synchronous emit_mcps batch, keeping its assertions.
check metadata-file raised only the failure context, so an MCE with no
aspects failed with just the file position. Include the failure message.

Also note in breaking-changes.md that check metadata-file now counts MCPs
and fails on an MCE with no aspects, and correct the import-cycle comment
in the REST emitter.
The file source now turns MCEs into MCPs, so the `aspect` option can
filter them like native MCP records instead of passing the whole MCE.
- The file source skips an MCE with no aspects with a report warning
  instead of failing the run, and gives each MCP from an MCE its own
  work unit id so failures name the aspect.
- The datahub-rest sink sends an MCE's aspects as one emit_mcps batch in
  SYNC/ASYNC mode, matching DataHubRestEmitter.
- datahub check metadata-file prints report warnings under its summary,
  so skipped records are visible.
- The file source catches errors from mcps_from_mce per record, so an MCE
  with an invalid URN is one report failure instead of stopping the file.
- breaking-changes.md notes that MCE files sent through the datahub-rest
  sink in SYNC/ASYNC mode show one timeline change per aspect.
- The aspect option and _emit_mce docstring describe MCE behaviour; a test
  covers emit(mce) over OpenAPI.
- MCE_DEPRECATION_MESSAGE and the once-per-process warn_mce_deprecated()
  live in generic_emitter, so the REST and Kafka emitters log it once
  between them instead of once each.
- The datahub-rest sink explains why it unpacks MCEs itself instead of
  calling emitter.emit().
- Tests: the sink test builds the sink like its neighbours, and the
  empty-MCE test checks the warning names the record, not the file.
…mce from emitter.mcp

The file source's empty-MCE warning now gives the URN as well as the
record position. The file source, REST sink and serde tests import
mcps_from_mce from its new home instead of the mcp_builder re-export.
Adds tests for the REST emitter sending nothing for an MCE with no
aspects, and for check metadata-file still accepting --unpack-mces.
…es and print plain report context

A file whose MCEs all have no aspects now also gets the per-file
deprecation warning. datahub check metadata-file joins report context
instead of printing the LossyList repr.
An empty MCE used to be submitted to the executor, where it sent nothing
but the done-callback still counted it in total_records_written. The sink
now reports it as a warning and acknowledges it with on_success before
submission, as the Kafka sink does, so it is not counted as written in
any mode.

This branch was successfully deployed

1 active deployment
Preview — 3922837f Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Issues and Improvements to docs ingestion PR or Issue related to the ingestion of metadata

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants