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;
}
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;
}
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;
}
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()));
}
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;
}
Aggregations