Skip to content

Conversation

@yaoforx
Copy link

@yaoforx yaoforx commented Dec 8, 2025

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

This change series adds validation to ensure clustering columns remain in the statistics schema when executing ALTER TABLE ALTER COLUMN col AFTER position commands on clustered Delta tables. Without proper stats schema handling, column reordering can cause clustering columns to lose statistics collection due to position-based indexing rules, degrading query optimization performance.

How was this patch tested?

The test suite verifies the following scenarios:

  1. checkEnabled=false (default):

    • First ALTER COLUMN AFTER succeeds (c1 moves after c3)
    • Second ALTER COLUMN AFTER succeeds (c2 moves after c3)
    • No validation errors thrown
    • Column order changes as expected
  2. checkEnabled=true:

    • First ALTER COLUMN AFTER succeeds (c1 moves after c3)
    • Second ALTER COLUMN AFTER fails with DELTA_CLUSTERING_COLUMN_MISSING_STATS error
    • Clustering column c2 would lose stats collection
    • Original schema and stats remain unchanged

Does this PR introduce any user-facing changes?

@yaoforx yaoforx changed the title OSS LC-11516 [Spark] Throw exception when validation fails in ALTER COLUMN AFTER Dec 9, 2025
Copy link
Collaborator

@rahulsmahadev rahulsmahadev left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, can you also update PR description to capture what we are doing

@yaoforx
Copy link
Author

yaoforx commented Dec 10, 2025

Thanks for the contribution, can you also update PR description to capture what we are doing

Done

@yaoforx yaoforx force-pushed the oss-cluster-key-validation branch from f7d16c3 to 3d20fa2 Compare December 10, 2025 06:14
@yaoforx yaoforx force-pushed the oss-cluster-key-validation branch from 3d20fa2 to 20f17df Compare December 10, 2025 23:32
Copy link
Collaborator

@zedtang zedtang left a comment

Choose a reason for hiding this comment

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

lgtm

@yaoforx yaoforx force-pushed the oss-cluster-key-validation branch from 20f17df to 032f6a3 Compare December 11, 2025 22:37
@yaoforx yaoforx force-pushed the oss-cluster-key-validation branch from 032f6a3 to 060f716 Compare December 11, 2025 23:11
Copy link
Collaborator

@rahulsmahadev rahulsmahadev left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants