use of org.apache.flink.table.planner.plan.trait.RelWindowProperties in project flink by apache.
the class RelTimeIndicatorConverter method gatherIndicesToMaterialize.
private Set<Integer> gatherIndicesToMaterialize(Aggregate agg, RelNode newInput) {
List<RelDataType> inputFieldTypes = RelOptUtil.getFieldTypeList(newInput.getRowType());
Predicate<Integer> isTimeIndicator = idx -> isTimeIndicatorType(inputFieldTypes.get(idx));
// add arguments of agg calls
Set<Integer> aggCallArgs = agg.getAggCallList().stream().map(AggregateCall::getArgList).flatMap(List::stream).filter(isTimeIndicator).collect(Collectors.toSet());
FlinkRelMetadataQuery fmq = FlinkRelMetadataQuery.reuseOrCreate(agg.getCluster().getMetadataQuery());
RelWindowProperties windowProps = fmq.getRelWindowProperties(newInput);
// add grouping sets
Set<Integer> groupSets = agg.getGroupSets().stream().map(grouping -> {
if (windowProps != null && groupingContainsWindowStartEnd(grouping, windowProps)) {
// of window_time column
return grouping.except(windowProps.getWindowTimeColumns());
} else {
return grouping;
}
}).flatMap(set -> set.asList().stream()).filter(isTimeIndicator).collect(Collectors.toSet());
Set<Integer> timeIndicatorIndices = new HashSet<>(aggCallArgs);
timeIndicatorIndices.addAll(groupSets);
return timeIndicatorIndices;
}
Aggregations