Skip to content

perf: avoid re-applying unchanged column tags on retained relations #1677

Description

@sd-db

Describe the problem

Column-level databricks_tags are emitted as one ALTER ... ALTER COLUMN ... SET TAGS statement per tagged column. Several materialization paths replay the full configured column-tag map, even on reruns where the relation may retain its existing column tags. With many tagged columns, these writes can dominate model runtime.

Column tags are currently applied by the table, incremental, view, materialized_view, streaming_table, and snapshot materializations.

Current reconciliation is inconsistent:

This should be tracked independently from relation-level databricks_tags, because the preservation and update behavior is per column and can differ by materialization lifecycle.

Expected behavior

For each supported materialization and lifecycle operation:

  1. Verify through server-observable functional tests whether the operation preserves existing column tags.
  2. When tags are preserved, fetch column-tag metadata only when column tags are configured and apply only new or changed keys.
  3. When the relation is newly created or dropped and recreated, apply the full desired column-tag map without fetching stale metadata.
  4. Preserve remote-only tags under the existing set-only reconciliation semantics.
  5. Ensure an unchanged rerun emits no column-tag writes when preservation is guaranteed.

The test matrix should cover:

  • Table V1 and V2 in-place replacement: coordinate with perf: apply only new or changed databricks_tags on table re-runs #1572.
  • Incremental ordinary rerun and in-place full refresh.
  • Snapshot rerun of the retained target table.
  • View replace and view_update_via_alter paths.
  • Materialized View refresh, alter, and replace paths.
  • Streaming Table refresh, alter, and replace paths.

View, Materialized View, and Streaming Table optimization should only be enabled after tests prove that the relevant Databricks operation retains column tags. Existing tests reapply the configured tags after lifecycle operations, so they do not establish preservation by themselves.

Fresh creates and drop-and-recreate paths are explicitly out of the optimization: they must continue to apply all configured column tags.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions