private boolean isAlwaysTrue(RexNode predicate) { if (predicate instanceof RexCall) { RexCall c = (RexCall) predicate; if (c.getOperator().getKind() == SqlKind.EQUALS) { int lPos = pos(c.getOperands().get(0)); int rPos = pos(c.getOperands().get(1)); return lPos != -1 && lPos == rPos; } } return predicate.isAlwaysTrue(); } }
if (!disjPred.isAlwaysTrue()) { preds.add(disjPred);
joinExprs, filterNulls, null); if (otherConditions.isAlwaysTrue()) {
/** * Translates "condition" to a Druid filter, assuming it does not contain any boolean expressions. Returns null * if we cannot translate the condition. * * @param plannerContext planner context * @param rowSignature row signature of the dataSource to be filtered * @param rexNode Calcite row expression */ @Nullable private static DimFilter toLeafFilter( final PlannerContext plannerContext, final RowSignature rowSignature, final RexNode rexNode ) { if (rexNode.isAlwaysTrue()) { return Filtration.matchEverything(); } else if (rexNode.isAlwaysFalse()) { return Filtration.matchNothing(); } final DimFilter simpleFilter = toSimpleLeafFilter(plannerContext, rowSignature, rexNode); return simpleFilter != null ? simpleFilter : toExpressionLeafFilter(plannerContext, rowSignature, rexNode); }
private boolean isAlwaysTrue(RexNode predicate) { if (predicate instanceof RexCall) { RexCall c = (RexCall) predicate; if (c.getOperator().getKind() == SqlKind.EQUALS) { int lPos = pos(c.getOperands().get(0)); int rPos = pos(c.getOperands().get(1)); return lPos != -1 && lPos == rPos; } } return predicate.isAlwaysTrue(); } }
/** Creates a {@link org.apache.calcite.rel.core.Filter} of a list of * predicates. * * <p>The predicates are combined using AND, * and optimized in a similar way to the {@link #and} method. * If the result is TRUE no filter is created. */ public HiveSubQRemoveRelBuilder filter(Iterable<? extends RexNode> predicates) { final RexNode x = RexUtil.simplifyAnds(cluster.getRexBuilder(), predicates, true); if (x.isAlwaysFalse()) { return empty(); } if (!x.isAlwaysTrue()) { final Frame frame = stack.pop(); final RelNode filter = filterFactory.createFilter(frame.rel, x); stack.push(new Frame(filter, frame.right)); } return this; }
if (!disjPred.isAlwaysTrue()) { preds.add(disjPred);
/** Creates a {@link org.apache.calcite.rel.core.Filter} of a list of * predicates. * * <p>The predicates are combined using AND, * and optimized in a similar way to the {@link #and} method. * If the result is TRUE no filter is created. */ public HiveSubQRemoveRelBuilder filter(Iterable<? extends RexNode> predicates) { final RexNode x = RexUtil.simplifyAnds(cluster.getRexBuilder(), predicates, true); if (x.isAlwaysFalse()) { return empty(); } if (!x.isAlwaysTrue()) { final Frame frame = stack.pop(); final RelNode filter = filterFactory.createFilter(frame.rel, x); stack.push(new Frame(filter, frame.right)); } return this; }
joinExprs, filterNulls, null); if (otherConditions.isAlwaysTrue()) {
MutableFilter createFilter(MutableFilter query, MutableFilter target) { final RexNode newCondition = splitFilter(query.cluster.getRexBuilder(), query.getCondition(), target.getCondition()); if (newCondition == null) { // Could not map query onto target. return null; } if (newCondition.isAlwaysTrue()) { return target; } return MutableFilter.of(target, newCondition); } }
@Override public RelBuilder filter(Iterable<? extends RexNode> predicates) { final RexNode x = RexUtil.simplify(cluster.getRexBuilder(), RexUtil.composeConjunction(cluster.getRexBuilder(), predicates, false)); if (!x.isAlwaysTrue()) { final RelNode input = build(); final RelNode filter = HiveRelFactories.HIVE_FILTER_FACTORY.createFilter(input, x); return this.push(filter); } return this; }
@Override public RelBuilder filter(Iterable<? extends RexNode> predicates) { final RexNode x = RexUtil.simplify(cluster.getRexBuilder(), RexUtil.composeConjunction(cluster.getRexBuilder(), predicates, false)); if (!x.isAlwaysTrue()) { final RelNode input = build(); final RelNode filter = HiveRelFactories.HIVE_FILTER_FACTORY.createFilter(input, x); return this.push(filter); } return this; }
@Override public boolean matches(RelOptRuleCall call) { final HiveJoin join = call.rel(0); final RexNode cond = join.getCondition(); final HiveJdbcConverter converter1 = call.rel(1); final HiveJdbcConverter converter2 = call.rel(2); // First we compare the convention if (!converter1.getJdbcConvention().getName().equals(converter2.getJdbcConvention().getName())) { return false; } // Second, we compare the connection string if (!converter1.getConnectionUrl().equals(converter2.getConnectionUrl())) { return false; } // Third, we compare the connection user if (!converter1.getConnectionUser().equals(converter2.getConnectionUser())) { return false; } //We do not push cross join if (cond.isAlwaysTrue()) { return false; } return JDBCRexCallValidator.isValidJdbcOperation(cond, converter1.getJdbcDialect()); }
if (join.getCondition().isAlwaysTrue()) { return; if (newLeftPredicate.isAlwaysTrue() && newRightPredicate.isAlwaysTrue()) { return; if (!newLeftPredicate.isAlwaysTrue()) { RelNode curr = lChild; lChild = filterFactory.createFilter(lChild, newLeftPredicate); call.getPlanner().onCopy(curr, lChild); if (!newRightPredicate.isAlwaysTrue()) { RelNode curr = rChild; rChild = filterFactory.createFilter(rChild, newRightPredicate);
if (join.getCondition().isAlwaysTrue()) { return; if (newLeftPredicate.isAlwaysTrue() && newRightPredicate.isAlwaysTrue()) { return; if (!newLeftPredicate.isAlwaysTrue()) { RelNode curr = lChild; lChild = filterFactory.createFilter(lChild, newLeftPredicate); call.getPlanner().onCopy(curr, lChild); if (!newRightPredicate.isAlwaysTrue()) { RelNode curr = rChild; rChild = filterFactory.createFilter(rChild, newRightPredicate);
operandsToPushDown); RexNode newPredicate = RexUtil.composeConjunction(rexBuilder, newConjuncts, false); if (newPredicate.isAlwaysTrue()) { return;
if (newLeftPredicate.isAlwaysTrue() && newRightPredicate.isAlwaysTrue()) { return; if (!newLeftPredicate.isAlwaysTrue()) { RelNode curr = lChild; lChild = filterFactory.createFilter( if (!newRightPredicate.isAlwaysTrue()) { RelNode curr = rChild; rChild = filterFactory.createFilter(
if (newLeftPredicate.isAlwaysTrue() && newRightPredicate.isAlwaysTrue()) { return; if (!newLeftPredicate.isAlwaysTrue()) { RelNode curr = lChild; lChild = filterFactory.createFilter(lChild, newLeftPredicate); if (!newRightPredicate.isAlwaysTrue()) { RelNode curr = rChild; rChild = filterFactory.createFilter(rChild, newRightPredicate);
if (newConditionExp.isAlwaysTrue()) { call.transformTo( filter.getInput());
if (newConditionExp.isAlwaysTrue()) { call.transformTo( filter.getInput());