You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/09/29 00:49:13 UTC

[GitHub] [hive] jfsii commented on a diff in pull request #3628: HIVE-26320: Deserialize Parquet VARCHAR and CHAR types appropriately

jfsii commented on code in PR #3628:
URL: https://github.com/apache/hive/pull/3628#discussion_r982970284


##########
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveSerDe.java:
##########
@@ -91,11 +93,61 @@ public class ParquetHiveSerDe extends AbstractSerDe implements SchemaInference {
 
   private ObjectInspector objInspector;
   private ParquetHiveRecord parquetRow;
+  private ObjectInspectorConverters.Converter converter;
 
   public ParquetHiveSerDe() {
     parquetRow = new ParquetHiveRecord();
   }
 
+  // Recursively check if CHAR or VARCHAR types are used
+  private boolean needsConversion(TypeInfo type) {
+    if (type.getTypeName().toLowerCase().startsWith(serdeConstants.CHAR_TYPE_NAME) ||
+        type.getTypeName().toLowerCase().startsWith(serdeConstants.VARCHAR_TYPE_NAME)) {
+      return true;
+    }
+
+    if (type.getCategory().equals(Category.STRUCT)) {
+      StructTypeInfo sti = (StructTypeInfo) type;
+      for (TypeInfo t : sti.getAllStructFieldTypeInfos()) {
+        if (needsConversion(t)) {
+          return true;
+        }
+      }
+    }
+
+    if (type.getCategory().equals(Category.MAP)) {
+      TypeInfo keyTypeInfo = ((MapTypeInfo) type).getMapKeyTypeInfo();
+      if (needsConversion(keyTypeInfo)) {
+        return true;
+      }
+      TypeInfo valueTypeInfo = ((MapTypeInfo) type).getMapKeyTypeInfo();

Review Comment:
   That is correct. Thanks for catching this @kasakrisz 



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

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org