Search in sources :

Example 1 with MetadataHandlerRel

use of org.apache.drill.exec.planner.logical.MetadataHandlerRel in project drill by apache.

the class MetastoreAnalyzeTableHandler method getTableAggRelNode.

private DrillRel getTableAggRelNode(DrillRel convertedRelNode, boolean createNewAggregations, List<SchemaPath> statisticsColumns, SchemaPath locationField, MetadataHandlerContext handlerContext) {
    SchemaPath lastModifiedTimeField = SchemaPath.getSimplePath(config.getContext().getOptions().getString(ExecConstants.IMPLICIT_LAST_MODIFIED_TIME_COLUMN_LABEL));
    List<SchemaPath> metadataColumns = Arrays.asList(locationField, lastModifiedTimeField);
    MetadataAggregateContext aggregateContext = MetadataAggregateContext.builder().groupByExpressions(Collections.emptyList()).interestingColumns(statisticsColumns).createNewAggregations(createNewAggregations).metadataColumns(metadataColumns).metadataLevel(MetadataType.TABLE).build();
    convertedRelNode = new MetadataAggRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, aggregateContext);
    convertedRelNode = new MetadataHandlerRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, handlerContext);
    return convertedRelNode;
}
Also used : MetadataAggRel(org.apache.drill.exec.planner.logical.MetadataAggRel) SchemaPath(org.apache.drill.common.expression.SchemaPath) MetadataHandlerRel(org.apache.drill.exec.planner.logical.MetadataHandlerRel) MetadataAggregateContext(org.apache.drill.exec.metastore.analyze.MetadataAggregateContext)

Example 2 with MetadataHandlerRel

use of org.apache.drill.exec.planner.logical.MetadataHandlerRel in project drill by apache.

the class MetastoreAnalyzeTableHandler method getSegmentAggRelNode.

private DrillRel getSegmentAggRelNode(List<NamedExpression> segmentExpressions, DrillRel convertedRelNode, boolean createNewAggregations, List<SchemaPath> statisticsColumns, SchemaPath locationField, int segmentLevel, MetadataHandlerContext handlerContext) {
    SchemaPath lastModifiedTimeField = SchemaPath.getSimplePath(config.getContext().getOptions().getString(ExecConstants.IMPLICIT_LAST_MODIFIED_TIME_COLUMN_LABEL));
    List<SchemaPath> metadataColumns = Arrays.asList(lastModifiedTimeField, locationField);
    List<NamedExpression> groupByExpressions = new ArrayList<>(segmentExpressions);
    MetadataAggregateContext aggregateContext = MetadataAggregateContext.builder().groupByExpressions(groupByExpressions.subList(0, segmentLevel)).interestingColumns(statisticsColumns).createNewAggregations(createNewAggregations).metadataColumns(metadataColumns).metadataLevel(MetadataType.SEGMENT).build();
    convertedRelNode = new MetadataAggRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, aggregateContext);
    convertedRelNode = new MetadataHandlerRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, handlerContext);
    return convertedRelNode;
}
Also used : MetadataAggRel(org.apache.drill.exec.planner.logical.MetadataAggRel) SchemaPath(org.apache.drill.common.expression.SchemaPath) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) ArrayList(java.util.ArrayList) MetadataHandlerRel(org.apache.drill.exec.planner.logical.MetadataHandlerRel) MetadataAggregateContext(org.apache.drill.exec.metastore.analyze.MetadataAggregateContext)

Example 3 with MetadataHandlerRel

use of org.apache.drill.exec.planner.logical.MetadataHandlerRel in project drill by apache.

the class MetastoreAnalyzeTableHandler method getFileAggRelNode.

private DrillRel getFileAggRelNode(List<NamedExpression> segmentExpressions, DrillRel convertedRelNode, boolean createNewAggregations, List<SchemaPath> statisticsColumns, SchemaPath locationField, MetadataHandlerContext handlerContext) {
    SchemaPath lastModifiedTimeField = SchemaPath.getSimplePath(config.getContext().getOptions().getString(ExecConstants.IMPLICIT_LAST_MODIFIED_TIME_COLUMN_LABEL));
    List<SchemaPath> metadataColumns = Arrays.asList(lastModifiedTimeField, locationField);
    NamedExpression locationExpression = new NamedExpression(locationField, FieldReference.getWithQuotedRef(MetastoreAnalyzeConstants.LOCATION_FIELD));
    List<NamedExpression> fileGroupByExpressions = new ArrayList<>(segmentExpressions);
    fileGroupByExpressions.add(locationExpression);
    MetadataAggregateContext aggregateContext = MetadataAggregateContext.builder().groupByExpressions(fileGroupByExpressions).interestingColumns(statisticsColumns).createNewAggregations(createNewAggregations).metadataColumns(metadataColumns).metadataLevel(MetadataType.FILE).build();
    convertedRelNode = new MetadataAggRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, aggregateContext);
    convertedRelNode = new MetadataHandlerRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, handlerContext);
    return convertedRelNode;
}
Also used : MetadataAggRel(org.apache.drill.exec.planner.logical.MetadataAggRel) SchemaPath(org.apache.drill.common.expression.SchemaPath) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) ArrayList(java.util.ArrayList) MetadataHandlerRel(org.apache.drill.exec.planner.logical.MetadataHandlerRel) MetadataAggregateContext(org.apache.drill.exec.metastore.analyze.MetadataAggregateContext)

Example 4 with MetadataHandlerRel

use of org.apache.drill.exec.planner.logical.MetadataHandlerRel in project drill by apache.

the class MetadataHandlerPrule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    MetadataHandlerRel relNode = call.rel(0);
    RelNode input = relNode.getInput();
    RelTraitSet traits = input.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(DrillDistributionTrait.SINGLETON);
    RelNode convertedInput = convert(input, traits);
    call.transformTo(new MetadataHandlerPrel(relNode.getCluster(), traits, convertedInput, relNode.getContext()));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) MetadataHandlerRel(org.apache.drill.exec.planner.logical.MetadataHandlerRel) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 5 with MetadataHandlerRel

use of org.apache.drill.exec.planner.logical.MetadataHandlerRel in project drill by apache.

the class MetastoreAnalyzeTableHandler method getRowGroupAggRelNode.

private DrillRel getRowGroupAggRelNode(List<NamedExpression> segmentExpressions, DrillRel convertedRelNode, boolean createNewAggregations, List<SchemaPath> statisticsColumns, MetadataHandlerContext handlerContext) {
    SchemaPath locationField = SchemaPath.getSimplePath(config.getContext().getOptions().getString(ExecConstants.IMPLICIT_FQN_COLUMN_LABEL));
    SchemaPath lastModifiedTimeField = SchemaPath.getSimplePath(config.getContext().getOptions().getString(ExecConstants.IMPLICIT_LAST_MODIFIED_TIME_COLUMN_LABEL));
    String rowGroupIndexColumn = config.getContext().getOptions().getString(ExecConstants.IMPLICIT_ROW_GROUP_INDEX_COLUMN_LABEL);
    SchemaPath rgiField = SchemaPath.getSimplePath(rowGroupIndexColumn);
    List<NamedExpression> rowGroupGroupByExpressions = getRowGroupExpressions(segmentExpressions, locationField, rowGroupIndexColumn, rgiField);
    SchemaPath rowGroupStartField = SchemaPath.getSimplePath(config.getContext().getOptions().getString(ExecConstants.IMPLICIT_ROW_GROUP_START_COLUMN_LABEL));
    SchemaPath rowGroupLengthField = SchemaPath.getSimplePath(config.getContext().getOptions().getString(ExecConstants.IMPLICIT_ROW_GROUP_LENGTH_COLUMN_LABEL));
    List<SchemaPath> metadataColumns = Arrays.asList(lastModifiedTimeField, locationField, rgiField, rowGroupStartField, rowGroupLengthField);
    MetadataAggregateContext aggregateContext = MetadataAggregateContext.builder().groupByExpressions(rowGroupGroupByExpressions).interestingColumns(statisticsColumns).createNewAggregations(createNewAggregations).metadataColumns(metadataColumns).metadataLevel(MetadataType.ROW_GROUP).build();
    convertedRelNode = new MetadataAggRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, aggregateContext);
    convertedRelNode = new MetadataHandlerRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode, handlerContext);
    return convertedRelNode;
}
Also used : MetadataAggRel(org.apache.drill.exec.planner.logical.MetadataAggRel) SchemaPath(org.apache.drill.common.expression.SchemaPath) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) MetadataHandlerRel(org.apache.drill.exec.planner.logical.MetadataHandlerRel) MetadataAggregateContext(org.apache.drill.exec.metastore.analyze.MetadataAggregateContext)

Aggregations

MetadataHandlerRel (org.apache.drill.exec.planner.logical.MetadataHandlerRel)5 SchemaPath (org.apache.drill.common.expression.SchemaPath)4 MetadataAggregateContext (org.apache.drill.exec.metastore.analyze.MetadataAggregateContext)4 MetadataAggRel (org.apache.drill.exec.planner.logical.MetadataAggRel)4 NamedExpression (org.apache.drill.common.logical.data.NamedExpression)3 ArrayList (java.util.ArrayList)2 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 RelNode (org.apache.calcite.rel.RelNode)1