drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinfengni <...@git.apache.org>
Subject [GitHub] drill pull request #637: Drill 1950 : Parquet row group filter pushdown.
Date Thu, 03 Nov 2016 23:33:46 GMT
Github user jinfengni commented on a diff in the pull request:

    https://github.com/apache/drill/pull/637#discussion_r86465657
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/stat/ParquetMetaStatCollector.java
---
    @@ -0,0 +1,146 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.drill.exec.store.parquet.stat;
    +
    +import org.apache.drill.common.expression.SchemaPath;
    +import org.apache.drill.common.types.TypeProtos;
    +import org.apache.drill.common.types.Types;
    +import org.apache.drill.exec.store.parquet.Metadata;
    +import org.apache.drill.exec.store.parquet.ParquetGroupScan;
    +import org.apache.parquet.column.statistics.BinaryStatistics;
    +import org.apache.parquet.column.statistics.DoubleStatistics;
    +import org.apache.parquet.column.statistics.FloatStatistics;
    +import org.apache.parquet.column.statistics.IntStatistics;
    +import org.apache.parquet.column.statistics.LongStatistics;
    +import org.apache.parquet.column.statistics.Statistics;
    +import org.apache.parquet.schema.OriginalType;
    +import org.apache.parquet.schema.PrimitiveType;
    +import org.joda.time.DateTimeConstants;
    +
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +
    +public class ParquetMetaStatCollector implements  ColumnStatCollector{
    +  private  final Metadata.ParquetTableMetadataBase parquetTableMetadata;
    +  private  final List<? extends Metadata.ColumnMetadata> columnMetadataList;
    +  final Map<String, String> implicitColValues;
    +
    +  public ParquetMetaStatCollector(Metadata.ParquetTableMetadataBase parquetTableMetadata,
List<? extends Metadata.ColumnMetadata> columnMetadataList, Map<String, String>
implicitColValues) {
    +    this.parquetTableMetadata = parquetTableMetadata;
    +    this.columnMetadataList = columnMetadataList;
    +    this.implicitColValues = implicitColValues;
    +  }
    +
    +  @Override
    +  public Map<SchemaPath, ColumnStatistics> collectColStat(Set<SchemaPath>
fields) {
    +    // map from column to ColumnMetadata
    +    final Map<SchemaPath, Metadata.ColumnMetadata> columnMetadataMap = new HashMap<>();
    +
    +    // map from column name to column statistics.
    +    final Map<SchemaPath, ColumnStatistics> statMap = new HashMap<>();
    +
    +    for (final Metadata.ColumnMetadata columnMetadata : columnMetadataList) {
    +      SchemaPath schemaPath = SchemaPath.getCompoundPath(columnMetadata.getName());
    +      columnMetadataMap.put(schemaPath, columnMetadata);
    +    }
    +
    +    for (final SchemaPath schemaPath : fields) {
    +      final PrimitiveType.PrimitiveTypeName primitiveType;
    +      final OriginalType originalType;
    +
    +      final Metadata.ColumnMetadata columnMetadata = columnMetadataMap.get(schemaPath);
    +
    +      if (columnMetadata != null) {
    +        final Object min = columnMetadata.getMinValue();
    +        final Object max = columnMetadata.getMaxValue();
    +        final Long numNull = columnMetadata.getNulls();
    +
    +        primitiveType = this.parquetTableMetadata.getPrimitiveType(columnMetadata.getName());
    +        originalType = this.parquetTableMetadata.getOriginalType(columnMetadata.getName());
    +        final Integer repetitionLevel = this.parquetTableMetadata.getRepetitionLevel(columnMetadata.getName());
    +
    +        statMap.put(schemaPath, getStat(min, max, numNull, primitiveType, originalType,
repetitionLevel));
    +      } else {
    +        final String columnName = schemaPath.getRootSegment().getPath();
    +        if (implicitColValues.containsKey(columnName)) {
    --- End diff --
    
    Without knowledge of implicit columns, expression materialization will treat dir0 in dir0
= 1995 as NULLEXPRESSION, and could not differentiate from a regular non-exist column.  A
condition on a regular non-exist column will always lead to canDrop = true. 
    
    That's the main reason we have to pass in the list of implicit columns when do expression
materialization.  
    
    In addition to implicit column name, we also pass in implicit column values, and wrap
them in Statistics instance with min and max having same value.  That is done to expand the
possibility of pruning. 
    
    For example, if we have regCol = 5 or dir0 = 1995.  If regCol is not a partition column,
we would not do any partition pruning in the current partition pruning logical. Pass the implicit
column values may allow us to prune some row groups using condition regCol = 5 or dir0 = 1995.
    
     I added explanations in comment. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message