fix: drop clustering key before dropping columns it references - #6095
Open
srujankgandla wants to merge 1 commit into
Open
srujankgandla wants to merge 1 commit into
srujankgandla wants to merge 1 commit into
Conversation
Signed-off-by: Srujan Kumar Gandla <srujankumar.dg@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5813.
When a model removes both a column and its
clustered_byin the same edit, the non-breaking path clones the table (the clone inherits the clustering key) and then issues ALTERs.ClusteredByMixin.get_alter_operationsappended the drop/replace clustering-key operation after the column alterations, so Snowflake receivedDROP COLUMNwhile the key still referenced it and rejected it with error 003203 — before the key was ever dropped.This change sequences the clustering-key operation first, so the key is dropped (or replaced) before any column it references is altered. It also fixes the latent twin: changing the key while dropping a column referenced by the old key.
Added
test_alter_table_drops_clustering_key_before_drop_column, which asserts the generated statement order on a mocked Snowflake adapter.Test Plan
test_alter_table_drops_clustering_key_before_drop_columnintests/core/engine_adapter/test_snowflake.py: on a mocked Snowflake adapterit asserts the generated statements are
ALTER TABLE "test_table" DROP CLUSTERING KEYfollowed byALTER TABLE "test_table" DROP COLUMN "b".python -m pytest tests/core/engine_adapter/test_snowflake.py -k "alter_table" -q→ 2 passed.ClusteredByMixinconsumers(Snowflake, BigQuery, StarRocks): 219 passed, 1 skipped; the only 2 failures
are pre-existing pandas-environment issues that fail identically on the clean tree.
ruff checkandruff format --checkclean on both changed files.Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCO