case UNION: final MutableUnion union = (MutableUnion) node; return LogicalUnion.create(fromMutables(union.inputs), union.all); case JOIN: final MutableJoin join = (MutableJoin) node;
public RelNode createSetOp(SqlKind kind, List<RelNode> inputs, boolean all) { switch (kind) { case UNION: return LogicalUnion.create(inputs, all); case EXCEPT: return LogicalMinus.create(inputs, all); case INTERSECT: return LogicalIntersect.create(inputs, all); default: throw new AssertionError("not a set op: " + kind); } } }
public RelNode createSetOp(SqlKind kind, List<RelNode> inputs, boolean all) { switch (kind) { case UNION: return LogicalUnion.create(inputs, all); case EXCEPT: return LogicalMinus.create(inputs, all); case INTERSECT: return LogicalIntersect.create(inputs, all); default: throw new AssertionError("not a set op: " + kind); } } }
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Union union = call.rel(1); final List<RelNode> newInputs = new ArrayList<>(); for (RelNode input : union.getInputs()) { final LogicalDelta newDelta = LogicalDelta.create(input); newInputs.add(newDelta); } final LogicalUnion newUnion = LogicalUnion.create(newInputs, union.all); call.transformTo(newUnion); } }
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Union union = call.rel(1); final List<RelNode> newInputs = new ArrayList<>(); for (RelNode input : union.getInputs()) { final LogicalDelta newDelta = LogicalDelta.create(input); newInputs.add(newDelta); } final LogicalUnion newUnion = LogicalUnion.create(newInputs, union.all); call.transformTo(newUnion); } }
break; default: builder.push(LogicalUnion.create(newInputs, union.all)); break;
unionInputs.add(values); resultRel = LogicalUnion.create(unionInputs, true);
break; default: builder.push(LogicalUnion.create(newInputs, union.all)); break;
/** * Converts a set operation (UNION, INTERSECT, MINUS) into relational * expressions. * * @param call Call to set operator * @return Relational expression */ protected RelNode convertSetOp(SqlCall call) { final RelNode left = convertQueryRecursive(call.operand(0), false, null).project(); final RelNode right = convertQueryRecursive(call.operand(1), false, null).project(); switch (call.getKind()) { case UNION: return LogicalUnion.create(ImmutableList.of(left, right), all(call)); case INTERSECT: return LogicalIntersect.create(ImmutableList.of(left, right), all(call)); case EXCEPT: return LogicalMinus.create(ImmutableList.of(left, right), all(call)); default: throw Util.unexpected(call.getKind()); } }
} else { bb.setRoot( LogicalUnion.create(unionRels, true), true);
} else { bb.setRoot( LogicalUnion.create(unionRels, true), true);
/** * Converts a set operation (UNION, INTERSECT, MINUS) into relational * expressions. * * @param call Call to set operator * @return Relational expression */ protected RelNode convertSetOp(SqlCall call) { final RelNode left = convertQueryRecursive(call.operand(0), false, null).project(); final RelNode right = convertQueryRecursive(call.operand(1), false, null).project(); switch (call.getKind()) { case UNION: return LogicalUnion.create(ImmutableList.of(left, right), all(call)); case INTERSECT: return LogicalIntersect.create(ImmutableList.of(left, right), all(call)); case EXCEPT: return LogicalMinus.create(ImmutableList.of(left, right), all(call)); default: throw Util.unexpected(call.getKind()); } }
public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Join join = call.rel(1); final RelNode left = join.getLeft(); final RelNode right = join.getRight(); final LogicalDelta rightWithDelta = LogicalDelta.create(right); final LogicalJoin joinL = LogicalJoin.create(left, rightWithDelta, join.getCondition(), join.getVariablesSet(), join.getJoinType(), join.isSemiJoinDone(), ImmutableList.copyOf(join.getSystemFieldList())); final LogicalDelta leftWithDelta = LogicalDelta.create(left); final LogicalJoin joinR = LogicalJoin.create(leftWithDelta, right, join.getCondition(), join.getVariablesSet(), join.getJoinType(), join.isSemiJoinDone(), ImmutableList.copyOf(join.getSystemFieldList())); List<RelNode> inputsToUnion = new ArrayList<>(); inputsToUnion.add(joinL); inputsToUnion.add(joinR); final LogicalUnion newNode = LogicalUnion.create(inputsToUnion, true); call.transformTo(newNode); } }
/** * Converts a set operation (UNION, INTERSECT, MINUS) into relational * expressions. * * @param call Call to set operator * @return Relational expression */ protected RelNode convertSetOp(SqlCall call) { final RelNode left = convertQueryRecursive(call.operand(0), false, null).project(); final RelNode right = convertQueryRecursive(call.operand(1), false, null).project(); switch (call.getKind()) { case UNION: return LogicalUnion.create(ImmutableList.of(left, right), all(call)); case INTERSECT: return LogicalIntersect.create(ImmutableList.of(left, right), all(call)); case EXCEPT: return LogicalMinus.create(ImmutableList.of(left, right), all(call)); default: throw Util.unexpected(call.getKind()); } }
} else { bb.setRoot( LogicalUnion.create(unionRels, true), true);
public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Join join = call.rel(1); final RelNode left = join.getLeft(); final RelNode right = join.getRight(); final LogicalDelta rightWithDelta = LogicalDelta.create(right); final LogicalJoin joinL = LogicalJoin.create(left, rightWithDelta, join.getCondition(), join.getVariablesSet(), join.getJoinType(), join.isSemiJoinDone(), ImmutableList.copyOf(join.getSystemFieldList())); final LogicalDelta leftWithDelta = LogicalDelta.create(left); final LogicalJoin joinR = LogicalJoin.create(leftWithDelta, right, join.getCondition(), join.getVariablesSet(), join.getJoinType(), join.isSemiJoinDone(), ImmutableList.copyOf(join.getSystemFieldList())); List<RelNode> inputsToUnion = new ArrayList<>(); inputsToUnion.add(joinL); inputsToUnion.add(joinR); final LogicalUnion newNode = LogicalUnion.create(inputsToUnion, true); call.transformTo(newNode); } }
} else { bb.setRoot( LogicalUnion.create(unionRels, true), true);
@Test public void testTableReferencesUnionUnknownNode() { final String sql = "select * from emp limit 10"; final RelNode node = convertSql(sql); final RelNode nodeWithUnknown = new DummyRelNode( node.getCluster(), node.getTraitSet(), node); // Union final LogicalUnion union = LogicalUnion.create(ImmutableList.of(nodeWithUnknown, node), true); final RelMetadataQuery mq = RelMetadataQuery.instance(); final Set<RelTableRef> tableReferences = mq.getTableReferences(union); assertNull(tableReferences); }
unionInputs.add(values); resultRel = LogicalUnion.create(unionInputs, true);
/** * Converts a set operation (UNION, INTERSECT, MINUS) into relational * expressions. * * @param call Call to set operator * @return Relational expression */ protected RelNode convertSetOp(SqlCall call) { final RelNode left = convertQueryRecursive(call.operand(0), false, null).project(); final RelNode right = convertQueryRecursive(call.operand(1), false, null).project(); switch (call.getKind()) { case UNION: return LogicalUnion.create(ImmutableList.of(left, right), all(call)); case INTERSECT: return LogicalIntersect.create(ImmutableList.of(left, right), all(call)); case EXCEPT: return LogicalMinus.create(ImmutableList.of(left, right), all(call)); default: throw Util.unexpected(call.getKind()); } }