private boolean filterRefersToBothSidesOfJoin(RexNode filter, Join j) { boolean refersToBothSides = false; int joinNoOfProjects = j.getRowType().getFieldCount(); ImmutableBitSet filterProjs = ImmutableBitSet.FROM_BIT_SET.apply(new BitSet(joinNoOfProjects)); ImmutableBitSet allLeftProjs = filterProjs.union(ImmutableBitSet.range(0, j.getInput(0) .getRowType().getFieldCount())); ImmutableBitSet allRightProjs = filterProjs.union(ImmutableBitSet.range(j.getInput(0) .getRowType().getFieldCount(), joinNoOfProjects)); filterProjs = filterProjs.union(InputFinder.bits(filter)); if (allLeftProjs.intersects(filterProjs) && allRightProjs.intersects(filterProjs)) refersToBothSides = true; return refersToBothSides; } }
private boolean filterRefersToBothSidesOfJoin(RexNode filter, Join j) { boolean refersToBothSides = false; int joinNoOfProjects = j.getRowType().getFieldCount(); ImmutableBitSet filterProjs = ImmutableBitSet.FROM_BIT_SET.apply(new BitSet(joinNoOfProjects)); ImmutableBitSet allLeftProjs = filterProjs.union(ImmutableBitSet.range(0, j.getInput(0) .getRowType().getFieldCount())); ImmutableBitSet allRightProjs = filterProjs.union(ImmutableBitSet.range(j.getInput(0) .getRowType().getFieldCount(), joinNoOfProjects)); filterProjs = filterProjs.union(InputFinder.bits(filter)); if (allLeftProjs.intersects(filterProjs) && allRightProjs.intersects(filterProjs)) refersToBothSides = true; return refersToBothSides; } }
if (projRefs0.intersects(inputsRange[i]) && projRefs0.union(inputsRange[i]).equals(inputsRange[i])) { if (leftKey == null) { foundBothInputs = true; } else if (projRefs1.intersects(inputsRange[i]) && projRefs1.union(inputsRange[i]).equals(inputsRange[i])) { if (leftKey == null) {
if (projRefs0.intersects(inputsRange[i]) && projRefs0.union(inputsRange[i]).equals(inputsRange[i])) { if (leftKey == null) { foundBothInputs = true; } else if (projRefs1.intersects(inputsRange[i]) && projRefs1.union(inputsRange[i]).equals(inputsRange[i])) { if (leftKey == null) {
join.getRowType().getFieldCount()); boolean leftInputPotentialFK = topRefs.intersects(leftBits); boolean rightInputPotentialFK = topRefs.intersects(rightBits); if (leftInputPotentialFK && rightInputPotentialFK && joinType == JoinRelType.INNER) { .map(projExpr -> projExpr.accept(new RexPermuteInputsShuttle(mappingRL, call.rel(1)))) .collect(Collectors.toList()); rightInputPotentialFK = RelOptUtil.InputFinder.bits(swappedTopProjExprs, null).intersects(rightBits); if (!rightInputPotentialFK) { topProjExprs = swappedTopProjExprs; .map(projExpr -> projExpr.accept(new RexPermuteInputsShuttle(mappingLR, call.rel(1)))) .collect(Collectors.toList()); leftInputPotentialFK = RelOptUtil.InputFinder.bits(swappedTopProjExprs, null).intersects(leftBits); if (!leftInputPotentialFK) { topProjExprs = swappedTopProjExprs;
ImmutableBitSet.range(left.getRowType().getFieldCount(), join.getRowType().getFieldCount()); if (topRefs.intersects(rightBits)) { return;
ImmutableBitSet.range(0, join.getLeft().getRowType().getFieldCount()); if (topRefs.intersects(leftBits)) { return;
ImmutableBitSet.range(left.getRowType().getFieldCount(), join.getRowType().getFieldCount()); if (bits.intersects(rightBits)) { return;
); if (bits.intersects(rightBits)) { return;
private boolean isStrong(final ImmutableBitSet exprArgs, final RexNode call) { // If the expressions do not use any of the inputs that require output to be null, // no need to check. Otherwise, check that the expression is null. // For example, in an "left outer join", we don't require that expressions // pushed down into the left input to be strong. On the other hand, // expressions pushed into the right input must be. In that case, // strongFields == right input fields. return !strongFields.intersects(exprArgs) || strong.isNull(call); }
private boolean isStrong(final ImmutableBitSet exprArgs, final RexNode call) { // If the expressions do not use any of the inputs that require output to be null, // no need to check. Otherwise, check that the expression is null. // For example, in an "left outer join", we don't require that expressions // pushed down into the left input to be strong. On the other hand, // expressions pushed into the right input must be. In that case, // strongFields == right input fields. return !strongFields.intersects(exprArgs) || strong.isNull(call); }
/** * Splits a condition into conjunctions that do or do not intersect with * a given bit set. */ static void split(RexNode condition, ImmutableBitSet bitSet, List<RexNode> intersecting, List<RexNode> nonIntersecting) { for (RexNode node : RelOptUtil.conjunctions(condition)) { ImmutableBitSet inputBitSet = RelOptUtil.InputFinder.bits(node); if (bitSet.intersects(inputBitSet)) { intersecting.add(node); } else { nonIntersecting.add(node); } } } }
/** * Splits a condition into conjunctions that do or do not intersect with * a given bit set. */ static void split(RexNode condition, ImmutableBitSet bitSet, List<RexNode> intersecting, List<RexNode> nonIntersecting) { for (RexNode node : RelOptUtil.conjunctions(condition)) { ImmutableBitSet inputBitSet = RelOptUtil.InputFinder.bits(node); if (bitSet.intersects(inputBitSet)) { intersecting.add(node); } else { nonIntersecting.add(node); } } } }
/** * Splits a condition into conjunctions that do or do not intersect with * a given bit set. */ static void split( RexNode condition, ImmutableBitSet bitSet, List<RexNode> intersecting, List<RexNode> nonIntersecting) { for (RexNode node : RelOptUtil.conjunctions(condition)) { ImmutableBitSet inputBitSet = RelOptUtil.InputFinder.bits(node); if (bitSet.intersects(inputBitSet)) { intersecting.add(node); } else { nonIntersecting.add(node); } } } }
/** * Splits a condition into conjunctions that do or do not intersect with * a given bit set. */ static void split( RexNode condition, ImmutableBitSet bitSet, List<RexNode> intersecting, List<RexNode> nonIntersecting) { for (RexNode node : RelOptUtil.conjunctions(condition)) { ImmutableBitSet inputBitSet = RelOptUtil.InputFinder.bits(node); if (bitSet.intersects(inputBitSet)) { intersecting.add(node); } else { nonIntersecting.add(node); } } } }
/** Converts an expression to a base or derived column reference. * The alias is optional, but if the derived column reference becomes * a dimension or measure, the alias will be used to choose a name. */ private ColRef toColRef(RexNode e, String alias) { if (e instanceof RexInputRef) { return h.column(((RexInputRef) e).getIndex()); } final ImmutableBitSet bits = RelOptUtil.InputFinder.bits(e); final ImmutableList.Builder<TableRef> tableRefs = ImmutableList.builder(); int c = 0; // offset within lattice of first column in a table for (TableRef tableRef : h.tableRefs) { final int prev = c; c += tableRef.table.t.getRowType().getFieldCount(); if (bits.intersects(ImmutableBitSet.range(prev, c))) { tableRefs.add(tableRef); } } return new DerivedColRef(tableRefs.build(), e, alias); } };
private boolean filterRefersToBothSidesOfJoin(RexNode filter, Join j) { boolean refersToBothSides = false; int joinNoOfProjects = j.getRowType().getFieldCount(); ImmutableBitSet filterProjs = ImmutableBitSet.FROM_BIT_SET.apply(new BitSet(joinNoOfProjects)); ImmutableBitSet allLeftProjs = filterProjs.union(ImmutableBitSet.range(0, j.getInput(0) .getRowType().getFieldCount())); ImmutableBitSet allRightProjs = filterProjs.union(ImmutableBitSet.range(j.getInput(0) .getRowType().getFieldCount(), joinNoOfProjects)); filterProjs = filterProjs.union(InputFinder.bits(filter)); if (allLeftProjs.intersects(filterProjs) && allRightProjs.intersects(filterProjs)) refersToBothSides = true; return refersToBothSides; } }
if (columnsMapped.intersects(rCols)) { final List<RexNode> list = new ArrayList<>(); for (int c : columnsMapped.intersect(rCols)) {
if (columnsMapped.intersects(rCols)) { final List<RexNode> list = new ArrayList<>(); for (int c : columnsMapped.intersect(rCols)) {
ImmutableBitSet.range(left.getRowType().getFieldCount(), join.getRowType().getFieldCount()); if (bits.intersects(rightBits)) { return;