本文整理汇总了Java中org.apache.calcite.rel.logical.LogicalJoin类的典型用法代码示例。如果您正苦于以下问题:Java LogicalJoin类的具体用法?Java LogicalJoin怎么用?Java LogicalJoin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LogicalJoin类属于org.apache.calcite.rel.logical包,在下文中一共展示了LogicalJoin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
@Override
public RelNode visit(LogicalJoin join) {
// to the best of my knowledge join.systemFieldList is always empty
Preconditions.checkState(join.getSystemFieldList().isEmpty(), "join.systemFieldList is not empty!");
final RelNode left = join.getLeft().accept(this);
final RelNode right = join.getRight().accept(this);
return new LogicalJoin(
cluster,
copyOf(join.getTraitSet()),
left,
right,
copyOf(join.getCondition()),
join.getVariablesSet(),
join.getJoinType(),
join.isSemiJoinDone(),
ImmutableList.<RelDataTypeField>of()
);
}
示例2: flatten
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
public void flatten(
List<RelNode> rels,
int systemFieldCount,
int[] start,
List<Pair<RelNode, Integer>> relOffsetList) {
for (RelNode rel : rels) {
if (leaves.contains(rel)) {
relOffsetList.add(
Pair.of(rel, start[0]));
start[0] += rel.getRowType().getFieldCount();
} else {
if (rel instanceof LogicalJoin
|| rel instanceof LogicalAggregate) {
start[0] += systemFieldCount;
}
flatten(
rel.getInputs(),
systemFieldCount,
start,
relOffsetList);
}
}
}
示例3: flatten
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
public void flatten(
List<RelNode> rels,
int systemFieldCount,
int[] start,
List<Pair<RelNode, Integer>> relOffsetList) {
for (RelNode rel : rels) {
if (leaves.contains(rel) || rel instanceof LogicalMatch) {
relOffsetList.add(
Pair.of(rel, start[0]));
start[0] += rel.getRowType().getFieldCount();
} else {
if (rel instanceof LogicalJoin
|| rel instanceof LogicalAggregate) {
start[0] += systemFieldCount;
}
flatten(
rel.getInputs(),
systemFieldCount,
start,
relOffsetList);
}
}
}
示例4: populate
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
private static boolean populate(List<RelNode> nodes, List<int[][]> tempLinks,
RelNode rel) {
if (nodes.isEmpty() && rel instanceof LogicalProject) {
return populate(nodes, tempLinks, ((LogicalProject) rel).getInput());
}
if (rel instanceof TableScan) {
nodes.add(rel);
return true;
}
if (rel instanceof LogicalJoin) {
LogicalJoin join = (LogicalJoin) rel;
if (join.getJoinType() != JoinRelType.INNER) {
throw new RuntimeException("only inner join allowed, but got "
+ join.getJoinType());
}
populate(nodes, tempLinks, join.getLeft());
populate(nodes, tempLinks, join.getRight());
for (RexNode rex : RelOptUtil.conjunctions(join.getCondition())) {
tempLinks.add(grab(nodes, rex));
}
return true;
}
throw new RuntimeException("Invalid node type "
+ rel.getClass().getSimpleName() + " in lattice query");
}
示例5: onMatch
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
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 = Lists.newArrayList();
inputsToUnion.add(joinL);
inputsToUnion.add(joinR);
final LogicalUnion newNode = LogicalUnion.create(inputsToUnion, true);
call.transformTo(newNode);
}
示例6: testSplitJoinCondition
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
/** 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));
}
示例7: visit
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
@Override
public RelNode visit(LogicalJoin join) {
final RexNode conditionExpr = join.getCondition().accept(unwrappingExpressionVisitor);
join = join.copy(join.getTraitSet(),
conditionExpr,
join.getLeft(),
join.getRight(),
join.getJoinType(),
join.isSemiJoinDone());
return visitChildren(join);
}
示例8: visit
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
@Override
public RelNode visit(LogicalJoin join) {
RexNode node = join.getCondition();
Set<List<String>> leftTables = getOriginTables(join.getLeft());
Set<List<String>> rightTables = getOriginTables(join.getRight());
InputCollector collector = new InputCollector(join);
node.accept(collector);
definitions.add(new JoinDefinition(join.getJoinType(), leftTables, rightTables, node, ImmutableMap.copyOf(collector.origins)));
return super.visit(join);
}
示例9: projectJoinOutputWithNullability
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
/**
* Pulls project above the join from its RHS input. Enforces nullability
* for join output.
*
* @param join Join
* @param project Original project as the right-hand input of the join
* @param nullIndicatorPos Position of null indicator
* @return the subtree with the new LogicalProject at the root
*/
private RelNode projectJoinOutputWithNullability(LogicalJoin join, LogicalProject project, int nullIndicatorPos) {
final RelDataTypeFactory typeFactory = join.getCluster().getTypeFactory();
final RelNode left = join.getLeft();
final JoinRelType joinType = join.getJoinType();
RexInputRef nullIndicator = new RexInputRef(nullIndicatorPos, typeFactory.createTypeWithNullability(join.getRowType().getFieldList().get(nullIndicatorPos).getType(), true));
// now create the new project
List<Pair<RexNode, String>> newProjExprs = Lists.newArrayList();
// project everything from the LHS and then those from the original
// projRel
List<RelDataTypeField> leftInputFields = left.getRowType().getFieldList();
for (int i = 0; i < leftInputFields.size(); i++) {
newProjExprs.add(RexInputRef.of2(i, leftInputFields));
}
// Marked where the projected expr is coming from so that the types will
// become nullable for the original projections which are now coming out
// of the nullable side of the OJ.
boolean projectPulledAboveLeftCorrelator = joinType.generatesNullsOnRight();
for (Pair<RexNode, String> pair : project.getNamedProjects()) {
RexNode newProjExpr = removeCorrelationExpr(pair.left, projectPulledAboveLeftCorrelator, nullIndicator);
newProjExprs.add(Pair.of(newProjExpr, pair.right));
}
return RelOptUtil.createProject(join, newProjExprs, false);
}
示例10: visit
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
@Override
public RelNode visit(LogicalJoin join) {
try {
stack.push(join);
join.getCondition().accept(rexVisitor(join));
} finally {
stack.pop();
}
return visitJoin(join);
}
示例11: convert
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
@Override
public RelNode convert(RelNode rel) {
LogicalJoin join = (LogicalJoin) rel;
final List<RelNode> newInputs = new ArrayList<>();
for (RelNode input : join.getInputs()) {
if (!(input.getConvention() == getOutTrait())) {
input = convert(input, input.getTraitSet().replace(getOut()));
}
newInputs.add(input);
}
if (!canJoinOnCondition(join.getCondition())) {
return null;
}
try {
return new JdbcJoin(
join.getCluster(),
join.getTraitSet().replace(getOut()),
newInputs.get(0),
newInputs.get(1),
join.getCondition(),
join.getJoinType(),
join.getVariablesStopped());
} catch (InvalidRelException e) {
LOGGER.fine(e.toString());
return null;
}
}
示例12: beginJoinStage
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
private void beginJoinStage(Join join) {
int[] ordinals = new int[2];
if (!RelOptUtil.analyzeSimpleEquiJoin((LogicalJoin) join, ordinals)) {
throw new UnsupportedOperationException("Only simple equi joins are supported");
}
pw.print(String.format(JOIN_STAGE_PROLOGUE, getStageName(join),
getStageName(join.getLeft()),
getStageName(join.getRight()),
ordinals[0],
ordinals[1]));
}
示例13: matches
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
public boolean matches(RelOptRuleCall call) {
LogicalJoin join = call.rel(0);
switch (join.getJoinType()) {
case INNER:
case LEFT:
return true;
case FULL:
case RIGHT:
return false;
default:
throw Util.unexpected(join.getJoinType());
}
}
示例14: convert
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
@Override public RelNode convert(RelNode rel) {
LogicalJoin join = (LogicalJoin) rel;
final List<RelNode> newInputs = new ArrayList<>();
for (RelNode input : join.getInputs()) {
if (!(input.getConvention() == getOutTrait())) {
input =
convert(input,
input.getTraitSet().replace(out));
}
newInputs.add(input);
}
if (!canJoinOnCondition(join.getCondition())) {
return null;
}
try {
return new JdbcJoin(
join.getCluster(),
join.getTraitSet().replace(out),
newInputs.get(0),
newInputs.get(1),
join.getCondition(),
join.getVariablesSet(),
join.getJoinType());
} catch (InvalidRelException e) {
LOGGER.debug(e.toString());
return null;
}
}
示例15: EnumerableJoinRule
import org.apache.calcite.rel.logical.LogicalJoin; //导入依赖的package包/类
EnumerableJoinRule() {
super(
LogicalJoin.class,
Convention.NONE,
EnumerableConvention.INSTANCE,
"EnumerableJoinRule");
}