okalinin commented on a change in pull request #1370: DRILL-5797: Use Parquet 
new reader in all non-complex column queries
URL: https://github.com/apache/drill/pull/1370#discussion_r201661782
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/AbstractParquetScanBatchCreator.java
 ##########
 @@ -191,4 +201,42 @@ protected AbstractDrillFileSystemManager(OperatorContext 
operatorContext) {
     protected abstract DrillFileSystem get(Configuration config, String path) 
throws ExecutionSetupException;
   }
 
+  /**
+   * Check whether any of queried columns is nested or repetitive.
+   *
+   * @param footer  Parquet file schema
+   * @param columns list of query SchemaPath objects
+   */
+  public static boolean containsComplexColumn(ParquetMetadata footer, 
List<SchemaPath> columns) {
+
+    Map<String, ColumnDescriptor> colDescMap = 
ParquetReaderUtility.getColNameToColumnDescriptorMapping(footer);
+    Map<String, SchemaElement> schemaElements = 
ParquetReaderUtility.getColNameToSchemaElementMapping(footer);
+
+    for (SchemaPath schemaPath : columns) {
+      // non-nested column check: full path must be equal to root segment path
+      if (!schemaPath.getUnIndexed().toString().replaceAll("`", "")
+          .equalsIgnoreCase(schemaPath.getRootSegment().getPath())) {
+        logger.debug("Forcing 'old' reader due to nested column: {}", 
schemaPath.getUnIndexed().toString());
+        return true;
+      }
+
+      // following column descriptor lookup failure may mean two cases, 
depending on subsequent SchemaElement lookup:
+      // 1. success: queried column is complex => use old reader
+      // 2. failure: queried column is not in schema => use new reader
+      ColumnDescriptor column = 
colDescMap.get(schemaPath.getUnIndexed().toString().toLowerCase());
+
+      if (column == null) {
+        SchemaElement se = 
schemaElements.get(schemaPath.getUnIndexed().toString().toLowerCase());
+        if (se != null) {
+          return true;
+        }
+      } else {
+        if (column.getMaxRepetitionLevel() > 0) {
+          logger.debug("Forcing 'old' reader due to repetitive column: {}", 
schemaPath.getUnIndexed().toString());
 
 Review comment:
   Fixed

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to