ihuzenko commented on a change in pull request #1829: DRILL-7096: Develop 
vector for canonical Map<K,V>
URL: https://github.com/apache/drill/pull/1829#discussion_r318078722
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataUtils.java
 ##########
 @@ -573,19 +585,30 @@ public static OriginalType 
getOriginalType(MetadataBase.ParquetTableMetadataBase
     for (MetadataBase.ParquetFileMetadata file : 
parquetTableMetadata.getFiles()) {
       // row groups in the file have the same schema, so using the first one
       Map<SchemaPath, TypeProtos.MajorType> fileColumns = 
getFileFields(parquetTableMetadata, file);
-      fileColumns.forEach((columnPath, type) -> {
-        TypeProtos.MajorType majorType = columns.get(columnPath);
-        if (majorType == null) {
-          columns.put(columnPath, type);
-        } else {
-          TypeProtos.MinorType leastRestrictiveType = 
TypeCastRules.getLeastRestrictiveType(Arrays.asList(majorType.getMinorType(), 
type.getMinorType()));
-          if (leastRestrictiveType != majorType.getMinorType()) {
-            columns.put(columnPath, type);
-          }
-        }
-      });
+      fileColumns.forEach((columnPath, type) -> putType(columns, columnPath, 
type));
+    }
+    return columns;
+  }
+
+  static Map<SchemaPath, TypeProtos.MajorType> 
resolveIntermediateFields(MetadataBase.ParquetTableMetadataBase 
parquetTableMetadata) {
+    LinkedHashMap<SchemaPath, TypeProtos.MajorType> columns = new 
LinkedHashMap<>();
+    for (MetadataBase.ParquetFileMetadata file : 
parquetTableMetadata.getFiles()) {
+      // row groups in the file have the same schema, so using the first one
+      Map<SchemaPath, TypeProtos.MajorType> fileColumns = 
getIntermediateFields(parquetTableMetadata, 
file.getRowGroups().iterator().next());
+      fileColumns.forEach((columnPath, type) -> putType(columns, columnPath, 
type));
     }
     return columns;
   }
 
+  static void putType(Map<SchemaPath, TypeProtos.MajorType> columns, 
SchemaPath columnPath, TypeProtos.MajorType type) {
 
 Review comment:
   Please make it private, add javadoc and reuse it inside 
```getIntermediateFields``` method

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


With regards,
Apache Git Services

Reply via email to