razajafri commented on a change in pull request #31284:
URL: https://github.com/apache/spark/pull/31284#discussion_r570430807



##########
File path: 
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedColumnReader.java
##########
@@ -145,7 +146,24 @@ public VectorizedColumnReader(
     DictionaryPage dictionaryPage = pageReader.readDictionaryPage();
     if (dictionaryPage != null) {
       try {
-        this.dictionary = 
dictionaryPage.getEncoding().initDictionary(descriptor, dictionaryPage);
+        PrimitiveType primitiveType = descriptor.getPrimitiveType();
+        if (primitiveType.getOriginalType() == OriginalType.DECIMAL &&
+            primitiveType.getDecimalMetadata().getPrecision() <= 
Decimal.MAX_INT_DIGITS() &&
+            primitiveType.getPrimitiveTypeName() == 
PrimitiveType.PrimitiveTypeName.INT64) {

Review comment:
       we will have to add a static import because it's not imported at the 
moment. I can do that for code-clarity
   
   The reason why it's working in other places in this file without the 
qualified name is because Java requires case statements to have `UNqualified` 
names of enums

##########
File path: 
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedColumnReader.java
##########
@@ -145,7 +146,24 @@ public VectorizedColumnReader(
     DictionaryPage dictionaryPage = pageReader.readDictionaryPage();
     if (dictionaryPage != null) {
       try {
-        this.dictionary = 
dictionaryPage.getEncoding().initDictionary(descriptor, dictionaryPage);
+        PrimitiveType primitiveType = descriptor.getPrimitiveType();
+        if (primitiveType.getOriginalType() == OriginalType.DECIMAL &&
+            primitiveType.getDecimalMetadata().getPrecision() <= 
Decimal.MAX_INT_DIGITS() &&
+            primitiveType.getPrimitiveTypeName() == 
PrimitiveType.PrimitiveTypeName.INT64) {
+          // We need to make sure that we initialize the right type for the 
dictionary otherwise
+          // Encoding#initDictionary will initialize it to 
PrimitiveTypeName.INT64 and
+          // WritableColumnVector will throw an exception when trying to 
decode to an Int when the
+          // dictionary is in fact initialized as Long
+          PrimitiveType adjustedType = new 
PrimitiveType(primitiveType.getRepetition(),
+              PrimitiveType.PrimitiveTypeName.INT32, 
primitiveType.getTypeLength(),

Review comment:
       same comment as above




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to