Search in sources :

Example 6 with ParquetTableMetadata_v4

use of org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4 in project drill by apache.

the class Metadata method getParquetTableMetadata.

/**
 * Get the parquet metadata for the parquet files in a directory.
 *
 * @param path the path of the directory
 * @return metadata object for an entire parquet directory structure
 * @throws IOException in case of problems during accessing files
 */
private ParquetTableMetadata_v4 getParquetTableMetadata(Path path, FileSystem fs) throws IOException {
    FileStatus fileStatus = fs.getFileStatus(path);
    Stopwatch watch = logger.isDebugEnabled() ? Stopwatch.createStarted() : null;
    List<FileStatus> fileStatuses = new ArrayList<>();
    if (fileStatus.isFile()) {
        fileStatuses.add(fileStatus);
    } else {
        // the thing we need!?
        fileStatuses.addAll(DrillFileSystemUtil.listFiles(fs, path, true));
    }
    if (watch != null) {
        logger.debug("Took {} ms to get file statuses", watch.elapsed(TimeUnit.MILLISECONDS));
        watch.reset();
        watch.start();
    }
    Map<FileStatus, FileSystem> fileStatusMap = fileStatuses.stream().collect(java.util.stream.Collectors.toMap(Function.identity(), s -> fs, (oldFs, newFs) -> newFs, LinkedHashMap::new));
    ParquetTableMetadata_v4 metadata_v4 = getParquetTableMetadata(fileStatusMap);
    if (watch != null) {
        logger.debug("Took {} ms to read file metadata", watch.elapsed(TimeUnit.MILLISECONDS));
        watch.stop();
    }
    return metadata_v4;
}
Also used : TimedCallable(org.apache.drill.exec.store.TimedCallable) ParquetTableMetadata_v4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4) FileSystem(org.apache.hadoop.fs.FileSystem) LoggerFactory(org.slf4j.LoggerFactory) FileStatus(org.apache.hadoop.fs.FileStatus) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) Pair(org.apache.commons.lang3.tuple.Pair) Configuration(org.apache.hadoop.conf.Configuration) Map(java.util.Map) Path(org.apache.hadoop.fs.Path) SHORT_PREFIX_STYLE(org.apache.commons.lang3.builder.ToStringStyle.SHORT_PREFIX_STYLE) ParquetTableMetadataBase(org.apache.drill.exec.store.parquet.metadata.MetadataBase.ParquetTableMetadataBase) Collectors(org.apache.drill.common.collections.Collectors) SchemaPath(org.apache.drill.common.expression.SchemaPath) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) RowGroupMetadata(org.apache.drill.exec.store.parquet.metadata.MetadataBase.RowGroupMetadata) AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) DrillFileSystemUtil(org.apache.drill.exec.util.DrillFileSystemUtil) List(java.util.List) FileMetadata(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.FileMetadata) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) Stopwatch(org.apache.drill.shaded.guava.com.google.common.base.Stopwatch) HadoopInputFile(org.apache.parquet.hadoop.util.HadoopInputFile) ParquetFileMetadata_v4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetFileMetadata_v4) ParquetReaderConfig(org.apache.drill.exec.store.parquet.ParquetReaderConfig) ParquetFileMetadata(org.apache.drill.exec.store.parquet.metadata.MetadataBase.ParquetFileMetadata) ParquetFileAndRowCountMetadata(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetFileAndRowCountMetadata) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) ImpersonationUtil(org.apache.drill.exec.util.ImpersonationUtil) PathSerDe(org.apache.drill.exec.serialization.PathSerDe) ColumnMetadata_v4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ColumnMetadata_v4) OutputStream(java.io.OutputStream) DrillVersionInfo(org.apache.drill.common.util.DrillVersionInfo) Logger(org.slf4j.Logger) JsonParser(com.fasterxml.jackson.core.JsonParser) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SUPPORTED_VERSIONS(org.apache.drill.exec.store.parquet.metadata.MetadataVersion.Constants.SUPPORTED_VERSIONS) IOException(java.io.IOException) MetadataContext(org.apache.drill.exec.store.dfs.MetadataContext) ParquetFileReader(org.apache.parquet.hadoop.ParquetFileReader) TimeUnit(java.util.concurrent.TimeUnit) JsonFactory(com.fasterxml.jackson.core.JsonFactory) Feature(com.fasterxml.jackson.core.JsonGenerator.Feature) Lists(org.apache.drill.shaded.guava.com.google.common.collect.Lists) ColumnTypeMetadata_v4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ColumnTypeMetadata_v4) ParquetMetadata(org.apache.parquet.hadoop.metadata.ParquetMetadata) MetadataSummary(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.MetadataSummary) InputStream(java.io.InputStream) FileStatus(org.apache.hadoop.fs.FileStatus) FileSystem(org.apache.hadoop.fs.FileSystem) Stopwatch(org.apache.drill.shaded.guava.com.google.common.base.Stopwatch) ArrayList(java.util.ArrayList) ParquetTableMetadata_v4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4)

Example 7 with ParquetTableMetadata_v4

use of org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4 in project drill by apache.

the class MetadataPathUtils method createMetadataWithRelativePaths.

/**
 * Creates a new parquet table metadata from the {@code tableMetadataWithAbsolutePaths} parquet table.
 * A new parquet table will contain relative paths for the files and directories.
 *
 * @param tableMetadataWithAbsolutePaths parquet table metadata with absolute paths for the files and directories
 * @param baseDir base parent directory
 * @return parquet table metadata with relative paths for the files and directories
 */
public static ParquetTableMetadata_v4 createMetadataWithRelativePaths(ParquetTableMetadata_v4 tableMetadataWithAbsolutePaths, Path baseDir) {
    List<Path> directoriesWithRelativePaths = new ArrayList<>();
    for (Path directory : tableMetadataWithAbsolutePaths.getDirectories()) {
        directoriesWithRelativePaths.add(relativize(baseDir, directory));
    }
    List<ParquetFileMetadata_v4> filesWithRelativePaths = new ArrayList<>();
    for (ParquetFileMetadata_v4 file : (List<ParquetFileMetadata_v4>) tableMetadataWithAbsolutePaths.getFiles()) {
        filesWithRelativePaths.add(new ParquetFileMetadata_v4(relativize(baseDir, file.getPath()), file.length, file.rowGroups));
    }
    return new ParquetTableMetadata_v4(SUPPORTED_VERSIONS.last().toString(), tableMetadataWithAbsolutePaths, filesWithRelativePaths, directoriesWithRelativePaths, DrillVersionInfo.getVersion(), tableMetadataWithAbsolutePaths.getTotalRowCount(), tableMetadataWithAbsolutePaths.isAllColumnsInteresting());
}
Also used : Path(org.apache.hadoop.fs.Path) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ParquetTableMetadata_v4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4) ParquetFileMetadata_v4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetFileMetadata_v4)

Example 8 with ParquetTableMetadata_v4

use of org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4 in project drill by apache.

the class AbstractParquetScanBatchCreator method getBatch.

protected ScanBatch getBatch(ExecutorFragmentContext context, AbstractParquetRowGroupScan rowGroupScan, OperatorContext oContext) throws ExecutionSetupException {
    final ColumnExplorer columnExplorer = new ColumnExplorer(context.getOptions(), rowGroupScan.getColumns());
    if (!columnExplorer.isStarQuery()) {
        rowGroupScan = rowGroupScan.copy(columnExplorer.getTableColumns());
        rowGroupScan.setOperatorId(rowGroupScan.getOperatorId());
    }
    AbstractDrillFileSystemManager fsManager = getDrillFileSystemCreator(oContext, context.getOptions());
    // keep footers in a map to avoid re-reading them
    Map<Path, ParquetMetadata> footers = new HashMap<>();
    List<CommonParquetRecordReader> readers = new LinkedList<>();
    List<Map<String, String>> implicitColumns = new ArrayList<>();
    Map<String, String> mapWithMaxColumns = new LinkedHashMap<>();
    ParquetReaderConfig readerConfig = rowGroupScan.getReaderConfig();
    // to be scanned in case ALL row groups are pruned out
    RowGroupReadEntry firstRowGroup = null;
    ParquetMetadata firstFooter = null;
    // for stats
    long rowGroupsPruned = 0;
    try {
        LogicalExpression filterExpr = rowGroupScan.getFilter();
        boolean doRuntimePruning = // was a filter given ?   And it is not just a "TRUE" predicate
        filterExpr != null && !((filterExpr instanceof ValueExpressions.BooleanExpression) && ((ValueExpressions.BooleanExpression) filterExpr).getBoolean());
        // Runtime pruning: Avoid recomputing metadata objects for each row-group in case they use the same file
        // by keeping the following objects computed earlier (relies on same file being in consecutive rowgroups)
        Path prevRowGroupPath = null;
        Metadata_V4.ParquetTableMetadata_v4 tableMetadataV4 = null;
        Metadata_V4.ParquetFileAndRowCountMetadata fileMetadataV4 = null;
        FilterPredicate<?> filterPredicate = null;
        Set<SchemaPath> schemaPathsInExpr = null;
        Set<SchemaPath> columnsInExpr = null;
        // for debug/info logging
        long totalPruneTime = 0;
        long totalRowGroups = rowGroupScan.getRowGroupReadEntries().size();
        Stopwatch pruneTimer = Stopwatch.createUnstarted();
        // If pruning - Prepare the predicate and the columns before the FOR LOOP
        if (doRuntimePruning) {
            filterPredicate = AbstractGroupScanWithMetadata.getFilterPredicate(filterExpr, context, context.getFunctionRegistry(), context.getOptions(), true, true, /* supports file implicit columns */
            rowGroupScan.getSchema());
            // Extract only the relevant columns from the filter (sans implicit columns, if any)
            schemaPathsInExpr = filterExpr.accept(FilterEvaluatorUtils.FieldReferenceFinder.INSTANCE, null);
            columnsInExpr = new HashSet<>();
            String partitionColumnLabel = context.getOptions().getOption(ExecConstants.FILESYSTEM_PARTITION_COLUMN_LABEL).string_val;
            for (SchemaPath path : schemaPathsInExpr) {
                if (rowGroupScan.supportsFileImplicitColumns() && path.toString().matches(partitionColumnLabel + "\\d+")) {
                    // skip implicit columns like dir0, dir1
                    continue;
                }
                columnsInExpr.add(SchemaPath.getSimplePath(path.getRootSegmentPath()));
            }
            // just in case: if no columns - cancel pruning
            doRuntimePruning = !columnsInExpr.isEmpty();
        }
        for (RowGroupReadEntry rowGroup : rowGroupScan.getRowGroupReadEntries()) {
            /*
        Here we could store a map from file names to footers, to prevent re-reading the footer for each row group in a file
        TODO - to prevent reading the footer again in the parquet record reader (it is read earlier in the ParquetStorageEngine)
        we should add more information to the RowGroupInfo that will be populated upon the first read to
        provide the reader with all of the file meta-data it needs
        These fields will be added to the constructor below
        */
            Stopwatch timer = logger.isTraceEnabled() ? Stopwatch.createUnstarted() : null;
            DrillFileSystem fs = fsManager.get(rowGroupScan.getFsConf(rowGroup), rowGroup.getPath());
            if (!footers.containsKey(rowGroup.getPath())) {
                if (timer != null) {
                    timer.start();
                }
                ParquetMetadata footer = readFooter(fs.getConf(), rowGroup.getPath(), readerConfig);
                if (timer != null) {
                    long timeToRead = timer.elapsed(TimeUnit.MICROSECONDS);
                    logger.trace("ParquetTrace,Read Footer,{},{},{},{},{},{},{}", "", rowGroup.getPath(), "", 0, 0, 0, timeToRead);
                }
                footers.put(rowGroup.getPath(), footer);
            }
            ParquetMetadata footer = footers.get(rowGroup.getPath());
            // 
            if (doRuntimePruning) {
                // skip when no filter or filter is TRUE
                pruneTimer.start();
                // 
                // Perform the Run-Time Pruning - i.e. Skip/prune this row group if the match fails
                // 
                // default (in case of exception) - do not prune this row group
                RowsMatch matchResult = RowsMatch.ALL;
                if (rowGroup.isEmpty()) {
                    matchResult = RowsMatch.NONE;
                } else {
                    int rowGroupIndex = rowGroup.getRowGroupIndex();
                    long footerRowCount = footer.getBlocks().get(rowGroupIndex).getRowCount();
                    // When starting a new file, or at the first time - Initialize the path specific metadata
                    if (!rowGroup.getPath().equals(prevRowGroupPath)) {
                        // Create a table metadata (V4)
                        tableMetadataV4 = new Metadata_V4.ParquetTableMetadata_v4();
                        // The file status for this file
                        FileStatus fileStatus = fs.getFileStatus(rowGroup.getPath());
                        // The file metadata (only for the columns used in the filter)
                        fileMetadataV4 = Metadata.getParquetFileMetadata_v4(tableMetadataV4, footer, fileStatus, fs, false, true, columnsInExpr, readerConfig);
                        // for next time
                        prevRowGroupPath = rowGroup.getPath();
                    }
                    MetadataBase.RowGroupMetadata rowGroupMetadata = fileMetadataV4.getFileMetadata().getRowGroups().get(rowGroup.getRowGroupIndex());
                    Map<SchemaPath, ColumnStatistics<?>> columnsStatistics = ParquetTableMetadataUtils.getRowGroupColumnStatistics(tableMetadataV4, rowGroupMetadata);
                    try {
                        Map<SchemaPath, TypeProtos.MajorType> intermediateColumns = ParquetTableMetadataUtils.getIntermediateFields(tableMetadataV4, rowGroupMetadata);
                        Map<SchemaPath, TypeProtos.MajorType> rowGroupFields = ParquetTableMetadataUtils.getRowGroupFields(tableMetadataV4, rowGroupMetadata);
                        TupleMetadata rowGroupSchema = new TupleSchema();
                        rowGroupFields.forEach((schemaPath, majorType) -> SchemaPathUtils.addColumnMetadata(rowGroupSchema, schemaPath, majorType, intermediateColumns));
                        // updates filter predicate to add required casts for the case when row group schema differs from the table schema
                        if (!rowGroupSchema.isEquivalent(rowGroupScan.getSchema())) {
                            filterPredicate = AbstractGroupScanWithMetadata.getFilterPredicate(filterExpr, context, context.getFunctionRegistry(), context.getOptions(), true, true, /* supports file implicit columns */
                            rowGroupSchema);
                        }
                        matchResult = FilterEvaluatorUtils.matches(filterPredicate, columnsStatistics, footerRowCount, rowGroupSchema, schemaPathsInExpr);
                        // collect logging info
                        long timeToRead = pruneTimer.elapsed(TimeUnit.MICROSECONDS);
                        totalPruneTime += timeToRead;
                        // trace each single row group
                        logger.trace(// trace each single row group
                        "Run-time pruning: {} row-group {} (RG index: {} row count: {}), took {} usec", matchResult == RowsMatch.NONE ? "Excluded" : "Included", rowGroup.getPath(), rowGroupIndex, footerRowCount, timeToRead);
                    } catch (Exception e) {
                        // in case some unexpected exception is raised
                        logger.warn("Run-time pruning check failed - {}. Skip pruning rowgroup - {}", e.getMessage(), rowGroup.getPath());
                        logger.debug("Failure during run-time pruning: {}", e.getMessage(), e);
                    }
                }
                pruneTimer.stop();
                pruneTimer.reset();
                // If this row group failed the match - skip it (i.e., no reader for this rowgroup)
                if (matchResult == RowsMatch.NONE) {
                    // one more RG was pruned
                    rowGroupsPruned++;
                    if (firstRowGroup == null) {
                        // keep the first RG, to be used in case all row groups are pruned
                        firstRowGroup = rowGroup;
                        firstFooter = footer;
                    }
                    // This Row group does not comply with the filter - prune it out and check the next Row Group
                    continue;
                }
            }
            mapWithMaxColumns = createReaderAndImplicitColumns(context, rowGroupScan, oContext, columnExplorer, readers, implicitColumns, mapWithMaxColumns, rowGroup, fs, footer, false);
        }
        // in case all row groups were pruned out - create a single reader for the first one (so that the schema could be returned)
        if (readers.isEmpty() && firstRowGroup != null) {
            DrillFileSystem fs = fsManager.get(rowGroupScan.getFsConf(firstRowGroup), firstRowGroup.getPath());
            mapWithMaxColumns = createReaderAndImplicitColumns(context, rowGroupScan, oContext, columnExplorer, readers, implicitColumns, mapWithMaxColumns, firstRowGroup, fs, firstFooter, true);
        }
        // do some logging, if relevant
        if (totalPruneTime > 0) {
            logger.info("Finished parquet_runtime_pruning in {} usec. Out of given {} rowgroups, {} were pruned. {}", totalPruneTime, totalRowGroups, rowGroupsPruned, totalRowGroups == rowGroupsPruned ? "ALL_PRUNED !!" : "");
        }
        // Update stats (same in every reader - the others would just overwrite the stats)
        for (CommonParquetRecordReader rr : readers) {
            rr.updateRowGroupsStats(totalRowGroups, rowGroupsPruned);
        }
    } catch (IOException | InterruptedException e) {
        throw new ExecutionSetupException(e);
    }
    // all readers should have the same number of implicit columns, add missing ones with value null
    Map<String, String> diff = Maps.transformValues(mapWithMaxColumns, Functions.constant(null));
    for (Map<String, String> map : implicitColumns) {
        map.putAll(Maps.difference(map, diff).entriesOnlyOnRight());
    }
    return new ScanBatch(context, oContext, readers, implicitColumns);
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Stopwatch(org.apache.drill.shaded.guava.com.google.common.base.Stopwatch) LinkedHashMap(java.util.LinkedHashMap) Metadata_V4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4) SchemaPath(org.apache.drill.common.expression.SchemaPath) ScanBatch(org.apache.drill.exec.physical.impl.ScanBatch) LinkedList(java.util.LinkedList) ColumnExplorer(org.apache.drill.exec.store.ColumnExplorer) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) MetadataBase(org.apache.drill.exec.store.parquet.metadata.MetadataBase) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) ParquetMetadata(org.apache.parquet.hadoop.metadata.ParquetMetadata) ValueExpressions(org.apache.drill.common.expression.ValueExpressions) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) DrillFileSystem(org.apache.drill.exec.store.dfs.DrillFileSystem) Path(org.apache.hadoop.fs.Path) SchemaPath(org.apache.drill.common.expression.SchemaPath) ColumnStatistics(org.apache.drill.metastore.statistics.ColumnStatistics) IOException(java.io.IOException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) IOException(java.io.IOException) RowsMatch(org.apache.drill.exec.expr.stat.RowsMatch) CommonParquetRecordReader(org.apache.drill.exec.store.CommonParquetRecordReader)

Example 9 with ParquetTableMetadata_v4

use of org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4 in project drill by apache.

the class ParquetTableMetadataUtils method getRowGroupFields.

/**
 * Returns map of column names with their drill types for specified {@code rowGroup}.
 *
 * @param parquetTableMetadata the source of primitive and original column types
 * @param rowGroup             row group whose columns should be discovered
 * @return map of column names with their drill types
 */
public static Map<SchemaPath, TypeProtos.MajorType> getRowGroupFields(MetadataBase.ParquetTableMetadataBase parquetTableMetadata, MetadataBase.RowGroupMetadata rowGroup) {
    Map<SchemaPath, TypeProtos.MajorType> columns = new LinkedHashMap<>();
    if (new MetadataVersion(parquetTableMetadata.getMetadataVersion()).isHigherThan(4, 0) && !((Metadata_V4.ParquetTableMetadata_v4) parquetTableMetadata).isAllColumnsInteresting()) {
        // adds non-interesting fields from table metadata
        for (MetadataBase.ColumnTypeMetadata columnTypeMetadata : parquetTableMetadata.getColumnTypeInfoList()) {
            Metadata_V4.ColumnTypeMetadata_v4 metadata = (Metadata_V4.ColumnTypeMetadata_v4) columnTypeMetadata;
            if (!metadata.isInteresting) {
                TypeProtos.MajorType columnType = getColumnType(metadata.name, metadata.primitiveType, metadata.originalType, parquetTableMetadata);
                SchemaPath columnPath = SchemaPath.getCompoundPath(metadata.name);
                putType(columns, columnPath, columnType);
            }
        }
    }
    for (MetadataBase.ColumnMetadata column : rowGroup.getColumns()) {
        TypeProtos.MajorType columnType = getColumnType(parquetTableMetadata, column);
        SchemaPath columnPath = SchemaPath.getCompoundPath(column.getName());
        putType(columns, columnPath, columnType);
    }
    return columns;
}
Also used : TypeProtos(org.apache.drill.common.types.TypeProtos) LinkedHashMap(java.util.LinkedHashMap) MetadataVersion(org.apache.drill.exec.store.parquet.metadata.MetadataVersion) Metadata_V4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4) SchemaPath(org.apache.drill.common.expression.SchemaPath) MetadataBase(org.apache.drill.exec.store.parquet.metadata.MetadataBase)

Example 10 with ParquetTableMetadata_v4

use of org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4 in project drill by apache.

the class ParquetTableMetadataUtils method getNonInterestingColumnsMeta.

/**
 * Returns the non-interesting column's metadata
 * @param parquetTableMetadata the source of column metadata for non-interesting column's statistics
 * @return returns non-interesting columns metadata
 */
public static NonInterestingColumnsMetadata getNonInterestingColumnsMeta(MetadataBase.ParquetTableMetadataBase parquetTableMetadata) {
    Map<SchemaPath, ColumnStatistics<?>> columnsStatistics = new HashMap<>();
    if (parquetTableMetadata instanceof Metadata_V4.ParquetTableMetadata_v4) {
        Map<Metadata_V4.ColumnTypeMetadata_v4.Key, Metadata_V4.ColumnTypeMetadata_v4> columnTypeInfoMap = ((Metadata_V4.ParquetTableMetadata_v4) parquetTableMetadata).getColumnTypeInfoMap();
        if (columnTypeInfoMap == null) {
            return new NonInterestingColumnsMetadata(columnsStatistics);
        }
        for (Metadata_V4.ColumnTypeMetadata_v4 columnTypeMetadata : columnTypeInfoMap.values()) {
            if (!columnTypeMetadata.isInteresting) {
                SchemaPath schemaPath = SchemaPath.getCompoundPath(columnTypeMetadata.name);
                List<StatisticsHolder<?>> statistics = new ArrayList<>();
                statistics.add(new StatisticsHolder<>(Statistic.NO_COLUMN_STATS, ColumnStatisticsKind.NULLS_COUNT));
                PrimitiveType.PrimitiveTypeName primitiveType = columnTypeMetadata.primitiveType;
                OriginalType originalType = columnTypeMetadata.originalType;
                TypeProtos.MinorType type = ParquetReaderUtility.getMinorType(primitiveType, originalType);
                columnsStatistics.put(schemaPath, new ColumnStatistics<>(statistics, type));
            }
        }
        return new NonInterestingColumnsMetadata(columnsStatistics);
    }
    return new NonInterestingColumnsMetadata(columnsStatistics);
}
Also used : ColumnStatistics(org.apache.drill.metastore.statistics.ColumnStatistics) NonInterestingColumnsMetadata(org.apache.drill.metastore.metadata.NonInterestingColumnsMetadata) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) TypeProtos(org.apache.drill.common.types.TypeProtos) StatisticsHolder(org.apache.drill.metastore.statistics.StatisticsHolder) OriginalType(org.apache.parquet.schema.OriginalType) Metadata_V4(org.apache.drill.exec.store.parquet.metadata.Metadata_V4) SchemaPath(org.apache.drill.common.expression.SchemaPath) PrimitiveType(org.apache.parquet.schema.PrimitiveType)

Aggregations

SchemaPath (org.apache.drill.common.expression.SchemaPath)8 LinkedHashMap (java.util.LinkedHashMap)6 ParquetTableMetadata_v4 (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetTableMetadata_v4)6 Path (org.apache.hadoop.fs.Path)6 ArrayList (java.util.ArrayList)5 MetadataSummary (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.MetadataSummary)5 IOException (java.io.IOException)4 Metadata_V4 (org.apache.drill.exec.store.parquet.metadata.Metadata_V4)4 ColumnTypeMetadata_v4 (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ColumnTypeMetadata_v4)4 ParquetFileAndRowCountMetadata (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetFileAndRowCountMetadata)4 ParquetFileMetadata_v4 (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ParquetFileMetadata_v4)4 Stopwatch (org.apache.drill.shaded.guava.com.google.common.base.Stopwatch)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)3 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)3 InputStream (java.io.InputStream)3 TypeProtos (org.apache.drill.common.types.TypeProtos)3 MetadataBase (org.apache.drill.exec.store.parquet.metadata.MetadataBase)3 ParquetFileMetadata (org.apache.drill.exec.store.parquet.metadata.MetadataBase.ParquetFileMetadata)3 FileMetadata (org.apache.drill.exec.store.parquet.metadata.Metadata_V4.FileMetadata)3