Skip to content

[parquet] Fix timestamp type and decimal type, if the file schema is not correctly match the schema in metadata - #5582

Merged
JingsongLi merged 4 commits into
apache:masterfrom
leaves12138:Fix_Read_type
May 9, 2025
Merged

[parquet] Fix timestamp type and decimal type, if the file schema is not correctly match the schema in metadata#5582
JingsongLi merged 4 commits into
apache:masterfrom
leaves12138:Fix_Read_type

Conversation

@leaves12138

Copy link
Copy Markdown
Contributor

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

@leaves12138
leaves12138 requested a review from Copilot May 9, 2025 04:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copilot AI May 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
for (int i = 0; i < 100; i++) {
int writePrecision = RANDOM.nextInt(10);
int readPrecision = writePrecision == 0 ? 0 : RANDOM.nextInt(writePrecision);

Copilot AI May 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

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.

3 participants