Skip to content

Commit 34c8d2e

Browse files
committed
rewrite isDecimalTypeMatched
1 parent 4b9daf3 commit 34c8d2e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedColumnReader.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ public class VectorizedColumnReader {
115115

116116
private boolean isDecimalTypeMatched(DataType dt) {
117117
DecimalType d = (DecimalType) dt;
118-
DecimalLogicalTypeAnnotation dm =
119-
(DecimalLogicalTypeAnnotation)descriptor.getPrimitiveType().getLogicalTypeAnnotation();
120-
// It's OK if the required decimal precision is larger than or equal to the physical decimal
121-
// precision in the Parquet metadata, as long as the decimal scale is the same.
122-
return dm != null && dm.getPrecision() <= d.precision() && dm.getScale() == d.scale();
118+
LogicalTypeAnnotation typeAnnotation = descriptor.getPrimitiveType().getLogicalTypeAnnotation();
119+
if (typeAnnotation instanceof DecimalLogicalTypeAnnotation) {
120+
DecimalLogicalTypeAnnotation decimalType = (DecimalLogicalTypeAnnotation) typeAnnotation;
121+
// It's OK if the required decimal precision is larger than or equal to the physical decimal
122+
// precision in the Parquet metadata, as long as the decimal scale is the same.
123+
return decimalType.getPrecision() <= d.precision() && decimalType.getScale() == d.scale();
124+
}
125+
return false;
123126
}
124127

125128
private boolean canReadAsIntDecimal(DataType dt) {

0 commit comments

Comments
 (0)