本文整理了Java中org.apache.calcite.plan.RelOptUtil.splitJoinCondition
方法的一些代码示例,展示了RelOptUtil.splitJoinCondition
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RelOptUtil.splitJoinCondition
方法的具体详情如下:
包路径:org.apache.calcite.plan.RelOptUtil
类名称:RelOptUtil
方法名:splitJoinCondition
[英]Splits out the equi-join (and optionally, a single non-equi) components of a join condition, and returns what's left. Projection might be required by the caller to provide join keys that are not direct field references.
[中]拆分联接条件的等联接(以及可选的单个非等联接)组件,并返回剩下的内容。调用方可能需要投影来提供非直接字段引用的联接键。
代码示例来源:origin: apache/hive
List<RexNode> rightJoinKeys = new ArrayList<RexNode>();
RexNode nonEquiConds = RelOptUtil.splitJoinCondition(sysFieldList, leftRel, rightRel,
calciteJoinCond, leftJoinKeys, rightJoinKeys, null, null);
代码示例来源:origin: apache/drill
List<RexNode> rightJoinKeys = new ArrayList<RexNode>();
RexNode nonEquiConds = RelOptUtil.splitJoinCondition(sysFieldList, leftRel, rightRel,
calciteJoinCond, leftJoinKeys, rightJoinKeys, null, null);
代码示例来源:origin: apache/hive
final List<Boolean> filterNulls = Lists.newArrayList();
RexNode nonEquiConj =
RelOptUtil.splitJoinCondition(join.getLeft(), join.getRight(),
join.getCondition(), leftKeys, rightKeys, filterNulls);
代码示例来源:origin: apache/drill
final List<Boolean> filterNulls = Lists.newArrayList();
RexNode nonEquiConj =
RelOptUtil.splitJoinCondition(join.getLeft(), join.getRight(),
join.getCondition(), leftKeys, rightKeys, filterNulls);
代码示例来源:origin: dremio/dremio-oss
public NestedLoopJoinPrel(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, RexNode condition,
JoinRelType joinType) throws InvalidRelException {
super(cluster, traits, left, right, condition, joinType);
RelOptUtil.splitJoinCondition(left, right, condition, leftKeys, rightKeys, filterNulls);
}
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
public DrillJoinRel(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, RexNode condition,
JoinRelType joinType, int joinControl) {
super(cluster, traits, left, right, condition, joinType);
assert traits.contains(DrillRel.DRILL_LOGICAL);
RelOptUtil.splitJoinCondition(left, right, condition, leftKeys, rightKeys, filterNulls);
this.joinControl = joinControl;
}
代码示例来源:origin: dremio/dremio-oss
/** Creates a JoinRel.
* We do not throw InvalidRelException in Logical planning phase. It's up to the post-logical planning check or physical planning
* to detect the unsupported join type, and throw exception.
* */
public JoinRel(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, RexNode condition,
JoinRelType joinType) {
super(cluster, traits, left, right, condition, joinType);
assert traits.contains(Rel.LOGICAL);
RelOptUtil.splitJoinCondition(left, right, condition, leftKeys, rightKeys, filterNulls);
}
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
public DrillJoinRel(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, RexNode condition,
JoinRelType joinType) {
super(cluster, traits, left, right, condition, joinType);
assert traits.contains(DrillRel.DRILL_LOGICAL);
RelOptUtil.splitJoinCondition(left, right, condition, leftKeys, rightKeys, filterNulls);
}
代码示例来源:origin: dremio/dremio-oss
public static JoinCategory getJoinCategory(RelNode left, RelNode right, RexNode condition,
List<Integer> leftKeys, List<Integer> rightKeys, List<Boolean> filterNulls) {
if (condition.isAlwaysTrue()) {
return JoinCategory.CARTESIAN;
}
leftKeys.clear();
rightKeys.clear();
filterNulls.clear();
RexNode remaining = RelOptUtil.splitJoinCondition(left, right, condition, leftKeys, rightKeys, filterNulls);
if (!remaining.isAlwaysTrue() || (leftKeys.size() == 0 || rightKeys.size() == 0) ) {
// for practical purposes these cases could be treated as inequality
return JoinCategory.INEQUALITY;
}
return JoinCategory.EQUALITY;
}
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
public static JoinCategory getJoinCategory(RelNode left, RelNode right, RexNode condition,
List<Integer> leftKeys, List<Integer> rightKeys, List<Boolean> filterNulls) {
if (condition.isAlwaysTrue()) {
return JoinCategory.CARTESIAN;
}
leftKeys.clear();
rightKeys.clear();
filterNulls.clear();
RexNode remaining = RelOptUtil.splitJoinCondition(left, right, condition, leftKeys, rightKeys, filterNulls);
if (!remaining.isAlwaysTrue() || (leftKeys.size() == 0 || rightKeys.size() == 0) ) {
// for practical purposes these cases could be treated as inequality
return JoinCategory.INEQUALITY;
}
return JoinCategory.EQUALITY;
}
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
if (joinType != JoinRelType.INNER) {
return true;
}
List<Integer> tmpLeftKeys = new ArrayList<>();
List<Integer> tmpRightKeys = new ArrayList<>();
List<Boolean> filterNulls = new ArrayList<>();
RexNode remaining =
RelOptUtil.splitJoinCondition(join.getLeft(), join.getRight(), exp, tmpLeftKeys, tmpRightKeys, filterNulls);
return remaining.isAlwaysTrue();
}
};
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
if (joinType != JoinRelType.INNER) {
return true; // In OUTER join, we could not pull-up the filter.
// All we can do is keep the filter with JOIN, and
// then decide whether the filter could be pushed down
// into LEFT/RIGHT.
}
List<RexNode> tmpLeftKeys = new ArrayList<>();
List<RexNode> tmpRightKeys = new ArrayList<>();
List<RelDataTypeField> sysFields = new ArrayList<>();
List<Integer> filterNulls = new ArrayList<>();
RexNode remaining = RelOptUtil.splitJoinCondition(sysFields, join.getLeft(), join.getRight(),
exp, tmpLeftKeys, tmpRightKeys, filterNulls, null);
return remaining.isAlwaysTrue();
}
};
代码示例来源:origin: Qihoo360/Quicksql
@Deprecated // to be removed before 2.0
public static boolean isEqui(
RelNode left,
RelNode right,
RexNode condition) {
final List<Integer> leftKeys = new ArrayList<>();
final List<Integer> rightKeys = new ArrayList<>();
final List<Boolean> filterNulls = new ArrayList<>();
final List<RexNode> nonEquiList = new ArrayList<>();
splitJoinCondition(
left.getCluster().getRexBuilder(),
left.getRowType().getFieldCount(),
condition,
leftKeys,
rightKeys,
filterNulls,
nonEquiList);
return nonEquiList.size() == 0;
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Deprecated // to be removed before 2.0
public static boolean isEqui(
RelNode left,
RelNode right,
RexNode condition) {
final List<Integer> leftKeys = new ArrayList<>();
final List<Integer> rightKeys = new ArrayList<>();
final List<Boolean> filterNulls = new ArrayList<>();
final List<RexNode> nonEquiList = new ArrayList<>();
splitJoinCondition(
left.getCluster().getRexBuilder(),
left.getRowType().getFieldCount(),
condition,
leftKeys,
rightKeys,
filterNulls,
nonEquiList);
return nonEquiList.size() == 0;
}
代码示例来源:origin: Qihoo360/Quicksql
/** Creates a {@code JoinInfo} by analyzing a condition. */
public static JoinInfo of(RelNode left, RelNode right, RexNode condition) {
final List<Integer> leftKeys = new ArrayList<>();
final List<Integer> rightKeys = new ArrayList<>();
final List<Boolean> filterNulls = new ArrayList<>();
RexNode remaining =
RelOptUtil.splitJoinCondition(left, right, condition, leftKeys,
rightKeys, filterNulls);
if (remaining.isAlwaysTrue()) {
return new EquiJoinInfo(ImmutableIntList.copyOf(leftKeys),
ImmutableIntList.copyOf(rightKeys));
} else {
return new NonEquiJoinInfo(ImmutableIntList.copyOf(leftKeys),
ImmutableIntList.copyOf(rightKeys), remaining);
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Creates a {@code JoinInfo} by analyzing a condition. */
public static JoinInfo of(RelNode left, RelNode right, RexNode condition) {
final List<Integer> leftKeys = new ArrayList<>();
final List<Integer> rightKeys = new ArrayList<>();
final List<Boolean> filterNulls = new ArrayList<>();
RexNode remaining =
RelOptUtil.splitJoinCondition(left, right, condition, leftKeys,
rightKeys, filterNulls);
if (remaining.isAlwaysTrue()) {
return new EquiJoinInfo(ImmutableIntList.copyOf(leftKeys),
ImmutableIntList.copyOf(rightKeys));
} else {
return new NonEquiJoinInfo(ImmutableIntList.copyOf(leftKeys),
ImmutableIntList.copyOf(rightKeys), remaining);
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
private static void splitJoinConditionHelper(RexNode joinCond, List<Integer> expLeftKeys,
List<Integer> expRightKeys, List<Boolean> expFilterNulls, RexNode expRemaining) {
List<Integer> actLeftKeys = new ArrayList<>();
List<Integer> actRightKeys = new ArrayList<>();
List<Boolean> actFilterNulls = new ArrayList<>();
RexNode actRemaining = RelOptUtil.splitJoinCondition(EMP_SCAN, DEPT_SCAN, joinCond, actLeftKeys,
actRightKeys, actFilterNulls);
assertEquals(expRemaining.toString(), actRemaining.toString());
assertEquals(expFilterNulls, actFilterNulls);
assertEquals(expLeftKeys, actLeftKeys);
assertEquals(expRightKeys, actRightKeys);
}
}
代码示例来源:origin: Qihoo360/Quicksql
private static void splitJoinConditionHelper(RexNode joinCond, List<Integer> expLeftKeys,
List<Integer> expRightKeys, List<Boolean> expFilterNulls, RexNode expRemaining) {
List<Integer> actLeftKeys = new ArrayList<>();
List<Integer> actRightKeys = new ArrayList<>();
List<Boolean> actFilterNulls = new ArrayList<>();
RexNode actRemaining = RelOptUtil.splitJoinCondition(EMP_SCAN, DEPT_SCAN, joinCond, actLeftKeys,
actRightKeys, actFilterNulls);
assertEquals(expRemaining.toString(), actRemaining.toString());
assertEquals(expFilterNulls, actFilterNulls);
assertEquals(expLeftKeys, actLeftKeys);
assertEquals(expRightKeys, actRightKeys);
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-833">[CALCITE-833]
* RelOptUtil.splitJoinCondition attempts to split a Join-Condition which
* has a remaining condition</a>. */
@Test public void testSplitJoinCondition() {
final String sql = "select * \n"
+ "from emp a \n"
+ "INNER JOIN dept b \n"
+ "ON CAST(a.empno AS int) <> b.deptno";
final RelNode relNode = toRel(sql);
final LogicalProject project = (LogicalProject) relNode;
final LogicalJoin join = (LogicalJoin) project.getInput(0);
final List<RexNode> leftJoinKeys = new ArrayList<>();
final List<RexNode> rightJoinKeys = new ArrayList<>();
final ArrayList<RelDataTypeField> sysFieldList = new ArrayList<>();
final RexNode remaining = RelOptUtil.splitJoinCondition(sysFieldList,
join.getInputs().get(0),
join.getInputs().get(1),
join.getCondition(),
leftJoinKeys,
rightJoinKeys,
null,
null);
assertThat(remaining.toString(), is("<>(CAST($0):INTEGER NOT NULL, $9)"));
assertThat(leftJoinKeys.isEmpty(), is(true));
assertThat(rightJoinKeys.isEmpty(), is(true));
}
代码示例来源:origin: Qihoo360/Quicksql
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-833">[CALCITE-833]
* RelOptUtil.splitJoinCondition attempts to split a Join-Condition which
* has a remaining condition</a>. */
@Test public void testSplitJoinCondition() {
final String sql = "select * \n"
+ "from emp a \n"
+ "INNER JOIN dept b \n"
+ "ON CAST(a.empno AS int) <> b.deptno";
final RelNode relNode = toRel(sql);
final LogicalProject project = (LogicalProject) relNode;
final LogicalJoin join = (LogicalJoin) project.getInput(0);
final List<RexNode> leftJoinKeys = new ArrayList<>();
final List<RexNode> rightJoinKeys = new ArrayList<>();
final ArrayList<RelDataTypeField> sysFieldList = new ArrayList<>();
final RexNode remaining = RelOptUtil.splitJoinCondition(sysFieldList,
join.getInputs().get(0),
join.getInputs().get(1),
join.getCondition(),
leftJoinKeys,
rightJoinKeys,
null,
null);
assertThat(remaining.toString(), is("<>(CAST($0):INTEGER NOT NULL, $9)"));
assertThat(leftJoinKeys.isEmpty(), is(true));
assertThat(rightJoinKeys.isEmpty(), is(true));
}
内容来源于网络,如有侵权,请联系作者删除!