Skip to content

fix: honor features.operationalMetadataEnabled when creating target table schema - #149

Draft
binlogreader wants to merge 1 commit into
databricks-solutions:mainfrom
binlogreader:fix/issue-97-operational-metadata-schema-gating
Draft

fix: honor features.operationalMetadataEnabled when creating target table schema#149
binlogreader wants to merge 1 commit into
databricks-solutions:mainfrom
binlogreader:fix/issue-97-operational-metadata-schema-gating

Conversation

@binlogreader

@binlogreader binlogreader commented Aug 26, 2026

Copy link
Copy Markdown

Fixes #97.

Operational metadata columns were appended to the target schema in BaseTargetDelta._initialize_schema, at construction time, before the per-spec features object exists. The read paths gate on features.operationalMetadataEnabled, so a spec disabling the feature produced a table whose schema carries metadata columns the written data never fills.

Changes

  • Defer the augmentation into create_table, gated on features and defaulting to enabled when absent, so call sites that pass nothing behave exactly as before. The per-target DISABLE_OPERATIONAL_METADATA config flag still wins, since it nulls the schema at construction.
  • Pass features=self.features at the two dataflow.py call sites that omitted it (streaming table and staging tables). The MV site already passes it, and the deferral also fixes the MV variant, where the data was gated but a schemaPath-backed schema was still augmented at init.
  • _add_columns is name-idempotent, so the SCD2 and quarantine columns added between construction and creation are unaffected. Quarantine tables are built without a schemaPath and never had the problem.

Tests

Four new unit tests in tests/unit/dataflow/test_target_base.py covering: features off, features on, features absent (defaults to enabled), and the config flag overriding an enabled features flag. Unit suite shows no new failures.

Opened as draft alongside a comment on #97; happy to adjust the approach if you'd prefer a different shape.

…able schema (databricks-solutions#97)

Operational metadata columns were appended to the target schema in
BaseTargetDelta._initialize_schema, at construction time, before the
per-spec features object exists. The read paths gate on
features.operationalMetadataEnabled, so a spec disabling the feature
produced a table whose schema carries metadata columns the written
data never fills.

Defer the augmentation into create_table, gated on features and
defaulting to enabled when absent, and pass features at the two
dataflow.py call sites that omitted it (streaming table and staging
tables). _add_columns is name-idempotent, so SCD2 and quarantine
columns added between construction and creation are unaffected.
Quarantine tables are built without a schemaPath and never had the
problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Operational metadata columns added to target schema when features.operationalMetadataEnabled is false

1 participant