Java Code Examples for org.apache.calcite.rel.logical.LogicalCorrelate#getLeft()
The following examples show how to use
org.apache.calcite.rel.logical.LogicalCorrelate#getLeft() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrillCorrelateRule.java From Bats with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall call) { final LogicalCorrelate correlate = call.rel(0); final RelNode left = correlate.getLeft(); final RelNode right = correlate.getRight(); final RelNode convertedLeft = convert(left, left.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify()); final RelNode convertedRight = convert(right, right.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify()); final RelTraitSet traits = correlate.getTraitSet().plus(DrillRel.DRILL_LOGICAL); DrillLateralJoinRel lateralJoinRel = new DrillLateralJoinRel(correlate.getCluster(), traits, convertedLeft, convertedRight, false, correlate.getCorrelationId(), correlate.getRequiredColumns(), correlate.getJoinType()); call.transformTo(lateralJoinRel); }
Example 2
Source File: ComplexUnnestVisitor.java From Bats with Apache License 2.0 | 4 votes |
@Override public RelNode visit(LogicalCorrelate correlate) { RelNode left = correlate.getLeft().accept(this); leftInputs.put(correlate.getCorrelationId(), left); RelNode right = correlate.getRight().accept(this); // if right input wasn't changed or left input wasn't changed // after rewriting right input, no need to create Correlate with new CorrelationId if (correlate.getRight() == right || left == leftInputs.get(correlate.getCorrelationId())) { if (correlate.getLeft() == left) { return correlate; } // changed only inputs, but CorrelationId left the same return correlate.copy(correlate.getTraitSet(), Arrays.asList(left, right)); } Correlate newCorrelate = correlate.copy(correlate.getTraitSet(), leftInputs.get(correlate.getCorrelationId()), right, updatedCorrelationIds.get(correlate.getCorrelationId()), ImmutableBitSet.of(left.getRowType().getFieldCount()), correlate.getJoinType()); RelBuilder builder = DrillRelFactories.LOGICAL_BUILDER.create(correlate.getCluster(), null); builder.push(newCorrelate); List<RexNode> topProjectExpressions = left.getRowType().getFieldList().stream() .map(field -> builder.getRexBuilder().makeInputRef(newCorrelate, field.getIndex())) .collect(Collectors.toList()); //Accommodate the new $COMPLEX_FIELD_NAME column. int rightStartIndex = left.getRowType().getFieldList().size() + 1; switch (correlate.getJoinType()) { case LEFT: case INNER: // adds field from the right input of correlate to the top project topProjectExpressions.addAll(right.getRowType().getFieldList().stream() .map(field -> builder.getRexBuilder().makeInputRef(newCorrelate, field.getIndex() + rightStartIndex)) .collect(Collectors.toList())); // fall through case ANTI: case SEMI: builder.project(topProjectExpressions, correlate.getRowType().getFieldNames()); } return builder.build(); }