Skip to content

[975] Convert Paimon partition values to typed values during sync - #1058

Open
shubhammittal92 wants to merge 1 commit into
apache:mainfrom
shubhammittal92:fix-975-paimon-typed-partition-values
Open

shubhammittal92 wants to merge 1 commit into
apache:mainfrom
shubhammittal92:fix-975-paimon-typed-partition-values

Conversation

@shubhammittal92

Copy link
Copy Markdown

Fixes #975

What is the purpose of the pull request

When Paimon is the source, a table partitioned by a non-STRING column failed to sync to Delta and Iceberg.

PaimonPartitionExtractor.toPartitionValues wrapped the raw partition-path strings from InternalRowPartitionComputer.generatePartValues directly in Range.scalar, so every partition value reached the targets as a String. The Delta and Iceberg targets expect the typed form the other sources produce (an Integer epoch day for DATE, an Integer for INT, a Long for BIGINT), so for a DATE/INT/BIGINT partition the sync failed with:

java.lang.ClassCastException: Cannot cast java.lang.String to java.lang.Integer

A null partition value also reached the targets as the string __DEFAULT_PARTITION__ instead of null.

Brief change log

  • Convert each Paimon partition value to its typed form based on the partition field's InternalType, reusing DeltaValueConverter.convertFromDeltaPartitionValue — the same converter DeltaKernelPartitionExtractor already reuses outside the delta package, which keeps Paimon's partition values consistent with the other sources.
  • Map the configured default-partition name (table.coreOptions().partitionDefaultName()) back to null.
  • Added unit tests for DATE/INT/LONG/STRING typing and for the null / default-partition sentinel.

Verify this pull request

This change added tests and can be verified as follows:

  • Added testConvertPartitionValueProducesTypedValues (asserts DATE→epoch-day Integer, INT→Integer, LONG→Long, STRING→String) and testConvertPartitionValueMapsNullAndDefaultPartitionToNull.
  • The existing real partitioned-table test (testToPartitionValuesWithPartitionedTable, STRING partition) continues to pass, confirming no regression on the common case.
  • spotless:check is clean.

Originally reported in #869.

PaimonPartitionExtractor.toPartitionValues wrapped the raw partition-path
strings from InternalRowPartitionComputer.generatePartValues directly in
Range.scalar, so every partition value reached the Delta and Iceberg targets as
a String. For a non-STRING partition column (DATE, INT, BIGINT, ...) the targets
expect the typed form the other sources produce (an epoch-day Integer for DATE,
an Integer for INT, a Long for BIGINT), so the sync failed with:
  java.lang.ClassCastException: Cannot cast java.lang.String to java.lang.Integer
A null partition value also reached the targets as the string
"__DEFAULT_PARTITION__" instead of null.

Convert each partition value to its typed form based on the partition field's
InternalType, reusing DeltaValueConverter.convertFromDeltaPartitionValue (the
same converter DeltaKernelPartitionExtractor already reuses outside the delta
package), and map the configured default-partition name back to null.

Tests: added unit tests in TestPaimonPartitionExtractor for DATE/INT/LONG/STRING
typing and for the null / default-partition sentinel. The existing real STRING
partitioned-table test continues to pass.

Signed-off-by: Shubham Mittal <shubmittal.92@gmail.com>

This branch has not been deployed

No deployments
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.

Paimon source passes non-STRING partition values as strings, breaking Delta and Iceberg sync

1 participant