Java源码示例:org.apache.calcite.adapter.enumerable.EnumerableUnion

示例1
@Test void testMultiInputsParentOpMatching() {
  VolcanoPlanner planner = new VolcanoPlanner();
  planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
  RelOptCluster cluster = newCluster(planner);

  // The trigger rule that generates PhysLeafRel from NoneLeafRel
  planner.addRule(new PhysLeafRule());

  // The rule with third child op matching PhysLeafRel, which should not be
  // matched at all
  planner.addRule(new ThreeInputsUnionRule());

  // Construct a union with only two children
  NoneLeafRel leftRel = new NoneLeafRel(cluster, "b");
  RelNode leftPhy = planner
      .changeTraits(leftRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION));
  PhysLeafRel rightPhy =
      new PhysLeafRel(cluster, PHYS_CALLING_CONVENTION, "b");

  planner.setRoot(
      new EnumerableUnion(cluster,
          cluster.traitSetOf(PHYS_CALLING_CONVENTION),
          Arrays.asList(leftPhy, rightPhy), false));

  planner.chooseDelegate().findBestExp();
}
 
示例2
private PlannerOp planEnumerableUnion(EnumerableUnion op, RelDataType rowType, boolean returnValues) {
    if (!op.all) {
        throw new StatementExecutionException("not suppoer UNION, all=false");
    }
    List<PlannerOp> inputs = new ArrayList<>(op.getInputs().size());
    for (RelNode input : op.getInputs()) {
        PlannerOp inputOp = convertRelNode(input, rowType, false, false).optimize();
        inputs.add(inputOp);
    }
    return new UnionAllOp(inputs);

}
 
示例3
ThreeInputsUnionRule() {
  super(
      operand(EnumerableUnion.class,
          some(
              operand(PhysBiRel.class, any()),
              operand(PhysBiRel.class, any()),
              operand(PhysLeafRel.class, any()))));
}