Java Code Examples for org.apache.calcite.rel.core.JoinRelType#SEMI

The following examples show how to use org.apache.calcite.rel.core.JoinRelType#SEMI . 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: FlinkSemiAntiJoinProjectTransposeRule.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean matches(RelOptRuleCall call) {
	LogicalJoin join = call.rel(0);
	LogicalProject project = call.rel(1);

	// only accept SEMI/ANTI join
	JoinRelType joinType = join.getJoinType();
	if (joinType != JoinRelType.SEMI && joinType != JoinRelType.ANTI) {
		return false;
	}
	// all expressions in Project should be RexInputRef
	for (RexNode p : project.getProjects()) {
		if (!(p instanceof RexInputRef)) {
			return false;
		}
	}
	return true;
}
 
Example 2
Source File: HBTQueryConvertor.java    From Mycat2 with GNU General Public License v3.0 6 votes vote down vote up
private JoinRelType joinOp(HBTOp op) {
    switch (op) {
        case INNER_JOIN:
            return JoinRelType.INNER;
        case LEFT_JOIN:
            return JoinRelType.LEFT;
        case RIGHT_JOIN:
            return JoinRelType.RIGHT;
        case FULL_JOIN:
            return JoinRelType.FULL;
        case SEMI_JOIN:
            return JoinRelType.SEMI;
        case ANTI_JOIN:
            return JoinRelType.ANTI;
        case CORRELATE_INNER_JOIN:
            return JoinRelType.INNER;
        case CORRELATE_LEFT_JOIN:
            return JoinRelType.LEFT;
        default:
            throw new UnsupportedOperationException();
    }
}
 
Example 3
Source File: FlinkSemiAntiJoinProjectTransposeRule.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean matches(RelOptRuleCall call) {
	LogicalJoin join = call.rel(0);
	LogicalProject project = call.rel(1);

	// only accept SEMI/ANTI join
	JoinRelType joinType = join.getJoinType();
	if (joinType != JoinRelType.SEMI && joinType != JoinRelType.ANTI) {
		return false;
	}
	// all expressions in Project should be RexInputRef
	for (RexNode p : project.getProjects()) {
		if (!(p instanceof RexInputRef)) {
			return false;
		}
	}
	return true;
}
 
Example 4
Source File: FlinkRelMdCollation.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the collation of {@link EnumerableHashJoin} based on its inputs and the join type.
 */
public static List<RelCollation> enumerableHashJoin(RelMetadataQuery mq,
		RelNode left, RelNode right, JoinRelType joinType) {
	if (joinType == JoinRelType.SEMI) {
		return enumerableSemiJoin(mq, left, right);
	} else {
		return enumerableJoin0(mq, left, right, joinType);
	}
}
 
Example 5
Source File: RelMdCollation.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the collation of {@link EnumerableHashJoin} based on its inputs and the join type.
 */
public static List<RelCollation> enumerableHashJoin(RelMetadataQuery mq,
    RelNode left, RelNode right, JoinRelType joinType) {
  if (joinType == JoinRelType.SEMI) {
    return enumerableSemiJoin(mq, left, right);
  } else {
    return enumerableJoin0(mq, left, right, joinType);
  }
}
 
Example 6
Source File: RelToSqlConverter.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** @see #dispatch */
public Result visit(Join e) {
  if (e.getJoinType() == JoinRelType.ANTI || e.getJoinType() == JoinRelType.SEMI) {
    return visitAntiOrSemiJoin(e);
  }
  final Result leftResult = visitChild(0, e.getLeft()).resetAlias();
  final Result rightResult = visitChild(1, e.getRight()).resetAlias();
  final Context leftContext = leftResult.qualifiedContext();
  final Context rightContext = rightResult.qualifiedContext();
  SqlNode sqlCondition = null;
  SqlLiteral condType = JoinConditionType.ON.symbol(POS);
  JoinType joinType = joinType(e.getJoinType());
  if (isCrossJoin(e)) {
    joinType = dialect.emulateJoinTypeForCrossJoin();
    condType = JoinConditionType.NONE.symbol(POS);
  } else {
    sqlCondition = convertConditionToSqlNode(e.getCondition(),
        leftContext,
        rightContext,
        e.getLeft().getRowType().getFieldCount(),
        dialect);
  }
  SqlNode join =
      new SqlJoin(POS,
          leftResult.asFrom(),
          SqlLiteral.createBoolean(false, POS),
          joinType.symbol(POS),
          rightResult.asFrom(),
          condType,
          sqlCondition);
  return result(join, leftResult, rightResult);
}
 
Example 7
Source File: EnumerableBatchNestedLoopJoinRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public boolean matches(RelOptRuleCall call) {
  Join join = call.rel(0);
  JoinRelType joinType = join.getJoinType();
  return joinType == JoinRelType.INNER
      || joinType == JoinRelType.LEFT
      || joinType == JoinRelType.ANTI
      || joinType == JoinRelType.SEMI;
}
 
Example 8
Source File: FlinkSemiAntiJoinFilterTransposeRule.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(RelOptRuleCall call) {
	LogicalJoin join = call.rel(0);
	return join.getJoinType() == JoinRelType.SEMI || join.getJoinType() == JoinRelType.ANTI;
}
 
Example 9
Source File: FlinkJoinToMultiJoinRule.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(RelOptRuleCall call) {
	final Join origJoin = call.rel(0);
	return origJoin.getJoinType() != JoinRelType.SEMI && origJoin.getJoinType() != JoinRelType.ANTI;
}
 
Example 10
Source File: FlinkSemiAntiJoinFilterTransposeRule.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(RelOptRuleCall call) {
	LogicalJoin join = call.rel(0);
	return join.getJoinType() == JoinRelType.SEMI || join.getJoinType() == JoinRelType.ANTI;
}