use of org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin in project flink by apache.
the class RelTimeIndicatorConverter method visitJoin.
private RelNode visitJoin(FlinkLogicalJoin join) {
RelNode newLeft = join.getLeft().accept(this);
RelNode newRight = join.getRight().accept(this);
int leftFieldCount = newLeft.getRowType().getFieldCount();
// temporal table join
if (TemporalJoinUtil.satisfyTemporalJoin(join, newLeft, newRight)) {
RelNode rewrittenTemporalJoin = join.copy(join.getTraitSet(), join.getCondition(), newLeft, newRight, join.getJoinType(), join.isSemiJoinDone());
// Materialize all of the time attributes from the right side of temporal join
Set<Integer> rightIndices = IntStream.range(0, newRight.getRowType().getFieldCount()).mapToObj(startIdx -> leftFieldCount + startIdx).collect(Collectors.toSet());
return createCalcToMaterializeTimeIndicators(rewrittenTemporalJoin, rightIndices);
} else {
if (JoinUtil.satisfyRegularJoin(join, newLeft, newRight)) {
// materialize time attribute fields of regular join's inputs
newLeft = materializeTimeIndicators(newLeft);
newRight = materializeTimeIndicators(newRight);
}
List<RelDataTypeField> leftRightFields = new ArrayList<>();
leftRightFields.addAll(newLeft.getRowType().getFieldList());
leftRightFields.addAll(newRight.getRowType().getFieldList());
RexNode newCondition = join.getCondition().accept(new RexShuttle() {
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
if (isTimeIndicatorType(inputRef.getType())) {
return RexInputRef.of(inputRef.getIndex(), leftRightFields);
} else {
return super.visitInputRef(inputRef);
}
}
});
return FlinkLogicalJoin.create(newLeft, newRight, newCondition, join.getJoinType());
}
}
Aggregations