Search in sources :

Example 1 with DrillStatsTable

use of org.apache.drill.exec.planner.common.DrillStatsTable in project drill by apache.

the class MetadataControllerBatch method getTableMetadata.

private BaseTableMetadata getTableMetadata(TupleReader reader, List<StatisticsHolder<?>> metadataStatistics, Map<SchemaPath, ColumnStatistics<?>> columnStatistics) {
    List<StatisticsHolder<?>> updatedMetaStats = new ArrayList<>(metadataStatistics);
    updatedMetaStats.add(new StatisticsHolder<>(popConfig.getContext().analyzeMetadataLevel(), TableStatisticsKind.ANALYZE_METADATA_LEVEL));
    MetadataInfo metadataInfo = MetadataInfo.builder().type(MetadataType.TABLE).key(MetadataInfo.GENERAL_INFO_KEY).build();
    BaseTableMetadata tableMetadata = BaseTableMetadata.builder().tableInfo(tableInfo).metadataInfo(metadataInfo).columnsStatistics(columnStatistics).metadataStatistics(updatedMetaStats).partitionKeys(Collections.emptyMap()).interestingColumns(popConfig.getContext().interestingColumns()).location(popConfig.getContext().location()).lastModifiedTime(Long.parseLong(reader.column(columnNamesOptions.lastModifiedTime()).scalar().getString())).schema(TupleMetadata.of(reader.column(MetastoreAnalyzeConstants.SCHEMA_FIELD).scalar().getString())).build();
    if (context.getOptions().getOption(PlannerSettings.STATISTICS_USE)) {
        DrillStatsTable statistics = new DrillStatsTable(statisticsCollector.getStatistics());
        Map<SchemaPath, ColumnStatistics<?>> tableColumnStatistics = ParquetTableMetadataUtils.getColumnStatistics(tableMetadata.getSchema(), statistics);
        tableMetadata = tableMetadata.cloneWithStats(tableColumnStatistics, DrillStatsTable.getEstimatedTableStats(statistics));
    }
    return tableMetadata;
}
Also used : ColumnStatistics(org.apache.drill.metastore.statistics.ColumnStatistics) StatisticsHolder(org.apache.drill.metastore.statistics.StatisticsHolder) MetadataInfo(org.apache.drill.metastore.metadata.MetadataInfo) DrillStatsTable(org.apache.drill.exec.planner.common.DrillStatsTable) BaseTableMetadata(org.apache.drill.metastore.metadata.BaseTableMetadata) SchemaPath(org.apache.drill.common.expression.SchemaPath) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 DrillStatsTable (org.apache.drill.exec.planner.common.DrillStatsTable)1 BaseTableMetadata (org.apache.drill.metastore.metadata.BaseTableMetadata)1 MetadataInfo (org.apache.drill.metastore.metadata.MetadataInfo)1 ColumnStatistics (org.apache.drill.metastore.statistics.ColumnStatistics)1 StatisticsHolder (org.apache.drill.metastore.statistics.StatisticsHolder)1