Repository navigation
fix: support INT32/INT64 physical types for decimal columns - #686
Merged
Merged
Conversation
Parquet decimals can be stored using multiple physical types depending on precision: - INT32 for precision <= 9 - INT64 for precision <= 18 - FIXED_LEN_BYTE_ARRAY for any precision - BYTE_ARRAY for any precision The previous implementation only accepted FIXED_LEN_BYTE_ARRAY for all decimals and rejected valid parquet files with error: unexpected physical type INT32 for decimal(7, 2), expected FIXED_LEN_BYTE_ARRAY This caused AddFiles to fail when importing datasets (like TPC-DS) that use INT32/INT64 for small precision decimals, which is valid per the Parquet specification. This change: - Refactors createStatsAgg to switch on Iceberg logical type first, then handle physical representations (matches iceberg-java's ParquetConversions.java approach) - For DecimalType, accepts all valid parquet physical types - Updates DataFileStatsFromMeta to handle INT32/INT64 decimal statistics - Adds wrappedDecByteArrayStats for BYTE_ARRAY encoded decimals
Member
|
Can we add a unit test and/or integration test for this? Otherwise this looks good to me |
Adds TestDecimalPhysicalTypes which creates Parquet files with decimals stored as INT32 (precision <= 9) and INT64 (precision <= 18) physical types, then verifies that DataFileStatsFromMeta correctly extracts column statistics without panicking. This test validates the fix for the decimal physical type handling.
zeroshade
approved these changes
Jan 22, 2026
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.
Summary
Parquet decimals can be stored using multiple physical types depending on precision:
INT32for precision <= 9INT64for precision <= 18FIXED_LEN_BYTE_ARRAYfor any precisionBYTE_ARRAYfor any precisionThe previous implementation only accepted
FIXED_LEN_BYTE_ARRAYfor all decimals and rejected valid parquet files with error:This caused
AddFilesto fail when importing datasets (like TPC-DS) that use INT32/INT64 for small precision decimals, which is valid per the Parquet specification.Changes
createStatsAggto switch on Iceberg logical type first, then handle physical representations (matches iceberg-java'sParquetConversions.javaapproach)DecimalType, accepts all valid parquet physical typesDataFileStatsFromMetato handle INT32/INT64 decimal statisticswrappedDecByteArrayStatsfor BYTE_ARRAY encoded decimalsTest plan