Repository navigation
Conversation
…partition columns When a partitioned table was written without the partition column values in the Parquet files (the default), ALTER TABLE ... REPLACE PARTITIONED BY now rewrites only those files within the same commit, instead of failing. Files that already store the partition columns are kept as-is (metadata-only). The rewrite mirrors OPTIMIZE: deletion vectors are applied, row tracking columns are preserved, and all actions are dataChange=false. Controlled by spark.databricks.delta.alterTable.replacePartitionedBy.rewriteNonMaterializedFiles (default true); when disabled, the command fails with an error listing the files and the config. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 task done
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Which Delta project/connector is this regarding?
Description
#17 makes dropping the partitioning a metadata-only operation, but it requires every data file to already store the partition column values in Parquet (e.g. written with
delta.writePartitionColumnsToParquet = true). By default, Delta does not write partition values into data files, so existing tables usually fail that check.With this change, the command rewrites only the files that are missing the partition columns, in the same commit as the metadata change:
partitionValues = {}(no rewrite), as in [Spark] Support ALTER TABLE ... REPLACE PARTITIONED BY WITH CLUSTER BY #17.dataChange = false.numRewrittenFiles,numRewrittenBytes,numAddedFilesFromRewrite.spark.databricks.delta.alterTable.replacePartitionedBy.rewriteNonMaterializedFiles(defaulttrue). When set tofalse, the command keeps the [Spark] Support ALTER TABLE ... REPLACE PARTITIONED BY WITH CLUSTER BY #17 behavior: it fails withDELTA_REPLACE_PARTITIONED_BY_PARTITION_COLUMNS_NOT_MATERIALIZED. The error message now names this conf.As a result, the cost of dropping the partitioning is proportional to the data that lacks partition values. Tables that already materialize them stay metadata-only.
How was this patch tested?
ReplacePartitionedByWithClusterBySuite:dataChange = false. Metrics are reported. Results, including null partition values and filters, are unchanged._metadata.row_id/row_commit_versionare preserved.RemoveFiles andnumRewrittenFiles = 0.Also ran
DeltaErrorsSuite,DeltaThrowableSuiteand scalastyle.Does this PR introduce any user-facing changes?
Yes.
ALTER TABLE ... REPLACE PARTITIONED BYno longer fails on tables whose data files don't store partition values; it rewrites those files instead. The previous behavior is available via the conf above.