Java Code Examples for org.apache.calcite.rel.logical.LogicalJoin#getInputs()

The following examples show how to use org.apache.calcite.rel.logical.LogicalJoin#getInputs() . 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: ElasticsearchJoinRule.java    From dk-fitting with Apache License 2.0 6 votes vote down vote up
public RelNode convert(RelNode relNode) {
    LogicalJoin join = (LogicalJoin) relNode;
    List<RelNode> newInputs = new ArrayList<RelNode>();
    for (RelNode input : join.getInputs()) {
        if (!(input.getConvention().getName().equals(ElasticsearchRelNode.CONVENTION.getName()))) {
            input =
                    convert(
                            input,
                            input.getTraitSet()
                                    .replace(ElasticsearchRelNode.CONVENTION));
        }
        newInputs.add(input);
    }
    final RelOptCluster cluster = join.getCluster();
    final RelTraitSet traitSet =
            join.getTraitSet().replace(ElasticsearchRelNode.CONVENTION);
    final RelNode left = newInputs.get(0);
    final RelNode right = newInputs.get(1);

    return new ElasticsearchJoin(join.getCluster(), traitSet, left, right,
            join.getCondition(), join.getJoinType());
}
 
Example 2
Source File: ElasticsearchJoinRule.java    From dk-fitting with Apache License 2.0 6 votes vote down vote up
public RelNode convert(RelNode relNode) {
    LogicalJoin join = (LogicalJoin) relNode;
    List<RelNode> newInputs = new ArrayList<RelNode>();
    for (RelNode input : join.getInputs()) {
        if (!(input.getConvention().getName().equals(ElasticsearchRelNode.CONVENTION.getName()))) {
            input =
                    convert(
                            input,
                            input.getTraitSet()
                                    .replace(ElasticsearchRelNode.CONVENTION));
        }
        newInputs.add(input);
    }
    final RelOptCluster cluster = join.getCluster();
    final RelTraitSet traitSet =
            join.getTraitSet().replace(ElasticsearchRelNode.CONVENTION);
    final RelNode left = newInputs.get(0);
    final RelNode right = newInputs.get(1);

    return new ElasticsearchJoin(join.getCluster(), traitSet, left, right,
            join.getCondition(), join.getJoinType());
}
 
Example 3
Source File: SqlHintsConverterTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Override public RelNode convert(RelNode rel) {
  LogicalJoin join = (LogicalJoin) rel;
  assertThat(join.getHints().size(), is(1));
  assertThat(join.getHints().get(0), is(expectedHint));
  List<RelNode> newInputs = new ArrayList<>();
  for (RelNode input : join.getInputs()) {
    if (!(input.getConvention() instanceof EnumerableConvention)) {
      input =
        convert(
          input,
          input.getTraitSet()
            .replace(EnumerableConvention.INSTANCE));
    }
    newInputs.add(input);
  }
  final RelOptCluster cluster = join.getCluster();
  final RelNode left = newInputs.get(0);
  final RelNode right = newInputs.get(1);
  final JoinInfo info = join.analyzeCondition();
  return EnumerableHashJoin.create(
    left,
    right,
    info.getEquiCondition(left, right, cluster.getRexBuilder()),
    join.getVariablesSet(),
    join.getJoinType());
}
 
Example 4
Source File: EnumerableJoinRule.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public RelNode convert(RelNode rel) {
  LogicalJoin join = (LogicalJoin) rel;
  List<RelNode> newInputs = new ArrayList<>();
  for (RelNode input : join.getInputs()) {
    if (!(input.getConvention() instanceof EnumerableConvention)) {
      input =
          convert(
              input,
              input.getTraitSet()
                  .replace(EnumerableConvention.INSTANCE));
    }
    newInputs.add(input);
  }
  final RexBuilder rexBuilder = join.getCluster().getRexBuilder();
  final RelNode left = newInputs.get(0);
  final RelNode right = newInputs.get(1);
  final JoinInfo info = join.analyzeCondition();

  // If the join has equiKeys (i.e. complete or partial equi-join),
  // create an EnumerableHashJoin, which supports all types of joins,
  // even if the join condition contains partial non-equi sub-conditions;
  // otherwise (complete non-equi-join), create an EnumerableNestedLoopJoin,
  // since a hash join strategy in this case would not be beneficial.
  final boolean hasEquiKeys = !info.leftKeys.isEmpty()
      && !info.rightKeys.isEmpty();
  if (hasEquiKeys) {
    // Re-arrange condition: first the equi-join elements, then the non-equi-join ones (if any);
    // this is not strictly necessary but it will be useful to avoid spurious errors in the
    // unit tests when verifying the plan.
    final RexNode equi = info.getEquiCondition(left, right, rexBuilder);
    final RexNode condition;
    if (info.isEqui()) {
      condition = equi;
    } else {
      final RexNode nonEqui = RexUtil.composeConjunction(rexBuilder, info.nonEquiConditions);
      condition = RexUtil.composeConjunction(rexBuilder, Arrays.asList(equi, nonEqui));
    }
    return EnumerableHashJoin.create(
        left,
        right,
        condition,
        join.getVariablesSet(),
        join.getJoinType());
  }
  return EnumerableNestedLoopJoin.create(
      left,
      right,
      join.getCondition(),
      join.getVariablesSet(),
      join.getJoinType());
}