[parquet] Fix timestamp type and decimal type, if the file schema is not correctly match the schema in metadata - #5582
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issues with timestamp and decimal type conversion when the file schema does not match the metadata by updating converter logic and adding test coverage.
- Added tests that exercise conversions for both TIMESTAMP and DECIMAL types.
- Modified lazy decoding checks in the vectorized reader to rely on the actual column vector type.
- Refactored the timestamp and decimal updater implementations to use precision-dependent logic.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| paimon-format/src/test/java/org/apache/paimon/format/parquet/reader/FileTypeNotMatchReadTypeTest.java | Added tests for timestamp and decimal conversion with variable precisions. |
| paimon-format/src/main/java/org/apache/paimon/format/parquet/reader/VectorizedColumnReader.java | Updated lazy decoding support to use the concrete column vector type. |
| paimon-format/src/main/java/org/apache/paimon/format/parquet/reader/ParquetVectorUpdaterFactory.java | Refactored timestamp and decimal updaters with precision logic and updated type parameters. |
| paimon-format/src/main/java/org/apache/paimon/format/parquet/reader/ParquetSplitReaderUtil.java | Removed unnecessary checkArgument conditions and cleaned up import statements. |
| } | ||
| } | ||
|
|
||
| protected void putDecimal(WritableColumnVector values, int offset, BigDecimal decimal) { |
There was a problem hiding this comment.
The putDecimal utility method is defined within the TimestampUpdater block but is used by other decimal updater classes. Consider moving this method to a shared utility class or the enclosing ParquetVectorUpdaterFactory to improve reuse and maintainability.
| for (int i = 0; i < 100; i++) { | ||
| int writePrecision = RANDOM.nextInt(10); | ||
| int readPrecision = writePrecision == 0 ? 0 : RANDOM.nextInt(writePrecision); | ||
|
|
There was a problem hiding this comment.
[nitpick] It would be helpful to add a brief comment explaining the rationale for forcing readPrecision to 4 when readPrecision is less than or equal to 3 and writePrecision is greater than 3, clarifying the test’s intent.
| // If the write precision is greater than 3 but the read precision is 3 or less, | |
| // we force the read precision to 4. This ensures the test covers scenarios where | |
| // the read precision exceeds the default precision for timestamps (3), which | |
| // might be necessary for compatibility or edge case testing. |
|
+1 |
…not correctly match the schema in metadata (#5582)
Purpose
If the timestamp field, in paimon, precision is 3. But in file, it is Binary. We will get an exception.
Fix this issue, do the converter for timestamp type and decimal type.
Tests
API and Format
Documentation