[spark] Support configurable dynamic partition column order - #9167
Draft
sablejade wants to merge 1 commit into
Draft
[spark] Support configurable dynamic partition column order#9167sablejade wants to merge 1 commit into
sablejade wants to merge 1 commit into
Conversation
2 tasks
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.
Purpose
This PR fixes a Spark dynamic partition write issue where positional writes may be incorrectly interpreted as Hive-style dynamic partition writes.
When writing to a partitioned Paimon table with Spark SQL dynamic partition syntax, the query output may already follow the target table schema order. However, the current logic may still treat it as Hive-style order and move dynamic partition columns from the tail. This can misalign columns, especially for UNION queries whose output names are inherited from the first branch.
For example, a UNION query may output columns in the correct table schema order, but one expression name, such as
detail_ratio, does not match the target column namevalue. The write is positional, so the value should still be written to thevaluecolumn. Relying only on output names can misclassify the query order and cause silent column misalignment when column types are compatible.This PR adds a configurable dynamic partition column order mode:
AUTO: preserve compatible behavior and automatically detect table-order or Hive-style-order writes.TABLE: always interpret positional dynamic partition writes using the target table schema order.HIVE: interpret dynamic partition writes using Hive-style order when applicable.Changes
spark.paimon.sql.dynamic-partition-column-order.AUTO,TABLE, andHIVEmodes.PARTITION (...)respect the configured column order when Hive-style output is applicable.Tests
PaimonDynamicPartitionColumnOrderTestCloses #9156