org.apache.calcite.rel.core.Filter Java Examples

The following examples show how to use org.apache.calcite.rel.core.Filter. 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: DruidQuery.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
    RelMetadataQuery mq) {
  return Util.last(rels)
      .computeSelfCost(planner, mq)
      // Cost increases with the number of fields queried.
      // A plan returning 100 or more columns will have 2x the cost of a
      // plan returning 2 columns.
      // A plan where all extra columns are pruned will be preferred.
      .multiplyBy(
          RelMdUtil.linear(querySpec.fieldNames.size(), 2, 100, 1d, 2d))
      .multiplyBy(getQueryTypeCostMultiplier())
      // A Scan leaf filter is better than having filter spec if possible.
      .multiplyBy(rels.size() > 1 && rels.get(1) instanceof Filter ? 0.5 : 1.0)
      // a plan with sort pushed to druid is better than doing sort outside of druid
      .multiplyBy(Util.last(rels) instanceof Sort ? 0.1 : 1.0)
      .multiplyBy(getIntervalCostMultiplier());
}
 
Example #2
Source File: RelOptUtil.java    From calcite with Apache License 2.0 6 votes vote down vote up
public static RexNode splitCorrelatedFilterCondition(
    Filter filter,
    List<RexNode> joinKeys,
    List<RexNode> correlatedJoinKeys,
    boolean extractCorrelatedFieldAccess) {
  final List<RexNode> nonEquiList = new ArrayList<>();

  splitCorrelatedFilterCondition(
      filter,
      filter.getCondition(),
      joinKeys,
      correlatedJoinKeys,
      nonEquiList,
      extractCorrelatedFieldAccess);

  // Convert the remainders into a list that are AND'ed together.
  return RexUtil.composeConjunction(
      filter.getCluster().getRexBuilder(), nonEquiList, true);
}
 
Example #3
Source File: RelMdDistinctRowCount.java    From calcite with Apache License 2.0 6 votes vote down vote up
public Double getDistinctRowCount(Filter rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey, RexNode predicate) {
  if (predicate == null || predicate.isAlwaysTrue()) {
    if (groupKey.isEmpty()) {
      return 1D;
    }
  }
  // REVIEW zfong 4/18/06 - In the Broadbase code, duplicates are not
  // removed from the two filter lists.  However, the code below is
  // doing so.
  RexNode unionPreds =
      RelMdUtil.unionPreds(
          rel.getCluster().getRexBuilder(),
          predicate,
          rel.getCondition());

  return mq.getDistinctRowCount(rel.getInput(), groupKey, unionPreds);
}
 
Example #4
Source File: RelMdSelectivity.java    From Bats with Apache License 2.0 6 votes vote down vote up
public Double getSelectivity(Filter rel, RelMetadataQuery mq,
    RexNode predicate) {
  // Take the difference between the predicate passed in and the
  // predicate in the filter's condition, so we don't apply the
  // selectivity of the filter twice.  If no predicate is passed in,
  // use the filter's condition.
  if (predicate != null) {
    return mq.getSelectivity(rel.getInput(),
        RelMdUtil.minusPreds(
            rel.getCluster().getRexBuilder(),
            predicate,
            rel.getCondition()));
  } else {
    return mq.getSelectivity(rel.getInput(), rel.getCondition());
  }
}
 
Example #5
Source File: RelNodeCompiler.java    From streamline with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitFilter(Filter filter, List<Void> inputStreams) throws Exception {
  beginStage(filter);

  List<RexNode> childExps = filter.getChildExps();
  RelDataType inputRowType = filter.getInput(0).getRowType();

  pw.print("Context context = new StreamlineContext(Processor.dataContext);\n");
  pw.print("context.values = _data.toArray();\n");
  pw.print("Object[] outputValues = new Object[1];\n");

  pw.write(rexCompiler.compileToBlock(childExps, inputRowType).toString());

  String r = "((Boolean) outputValues[0])";
  if (filter.getCondition().getType().isNullable()) {
    pw.print(String.format("    if (%s != null && %s) { ctx.emit(_data); }\n", r, r));
  } else {
    pw.print(String.format("    if (%s) { ctx.emit(_data); }\n", r, r));
  }
  endStage();
  return null;
}
 
Example #6
Source File: PruneScanRuleBase.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void onMatch(RelOptRuleCall call) {
  final Filter filterRel = call.rel(0);
  final Project projectRel = call.rel(1);
  final T scanRel = call.rel(2);
  doOnMatch(call, filterRel, projectRel, scanRel);
}
 
Example #7
Source File: DateRangeRules.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Override
public void onMatch(RelOptRuleCall call) {
    final Filter filter = call.rel(0);
    final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
    final String timeZone = filter.getCluster().getPlanner().getContext().unwrap(CalciteConnectionConfig.class)
            .timeZone();
    final RexNode condition = replaceTimeUnits(rexBuilder, filter.getCondition(), timeZone);
    if (condition.equals(filter.getCondition())) {
        return;
    }
    final RelBuilder relBuilder = relBuilderFactory.create(filter.getCluster(), null);
    relBuilder.push(filter.getInput()).filter(condition);
    call.transformTo(relBuilder.build());
}
 
Example #8
Source File: FilterMergeRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
  final Filter topFilter = call.rel(0);
  final Filter bottomFilter = call.rel(1);

  final RelBuilder relBuilder = call.builder();
  relBuilder.push(bottomFilter.getInput())
      .filter(bottomFilter.getCondition(), topFilter.getCondition());

  call.transformTo(relBuilder.build());
}
 
Example #9
Source File: MaterializedViewAggregateRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Creates a MaterializedViewAggregateRule. */
protected MaterializedViewAggregateRule(RelOptRuleOperand operand,
    RelBuilderFactory relBuilderFactory, String description,
    boolean generateUnionRewriting, HepProgram unionRewritingPullProgram) {
  this(operand, relBuilderFactory, description, generateUnionRewriting,
      unionRewritingPullProgram,
      new FilterProjectTransposeRule(
          Filter.class, Project.class, true, true, relBuilderFactory),
      new FilterAggregateTransposeRule(
          Filter.class, relBuilderFactory, Aggregate.class),
      new AggregateProjectPullUpConstantsRule(
          Aggregate.class, Filter.class, relBuilderFactory, "AggFilterPullUpConstants"),
      new ProjectMergeRule(true, ProjectMergeRule.DEFAULT_BLOAT,
          relBuilderFactory));
}
 
Example #10
Source File: RelMdColumnUniqueness.java    From calcite with Apache License 2.0 5 votes vote down vote up
public Boolean areColumnsUnique(RelSubset rel, RelMetadataQuery mq,
    ImmutableBitSet columns, boolean ignoreNulls) {
  columns = decorateWithConstantColumnsFromPredicates(columns, rel, mq);
  int nullCount = 0;
  for (RelNode rel2 : rel.getRels()) {
    if (rel2 instanceof Aggregate
        || rel2 instanceof Filter
        || rel2 instanceof Values
        || rel2 instanceof Sort
        || rel2 instanceof TableScan
        || simplyProjects(rel2, columns)) {
      try {
        final Boolean unique = mq.areColumnsUnique(rel2, columns, ignoreNulls);
        if (unique != null) {
          if (unique) {
            return true;
          }
        } else {
          ++nullCount;
        }
      } catch (CyclicMetadataException e) {
        // Ignore this relational expression; there will be non-cyclic ones
        // in this set.
      }
    }
  }
  return nullCount == 0 ? false : null;
}
 
Example #11
Source File: AbstractMaterializedViewRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/** Creates a MaterializedViewAggregateRule. */
protected MaterializedViewAggregateRule(RelOptRuleOperand operand, RelBuilderFactory relBuilderFactory,
        String description, boolean generateUnionRewriting, HepProgram unionRewritingPullProgram) {
    super(operand, relBuilderFactory, description, generateUnionRewriting, unionRewritingPullProgram, false);
    this.filterProjectTransposeRule = new FilterProjectTransposeRule(Filter.class, Project.class, true, true,
            relBuilderFactory);
    this.filterAggregateTransposeRule = new FilterAggregateTransposeRule(Filter.class, relBuilderFactory,
            Aggregate.class);
    this.aggregateProjectPullUpConstantsRule = new AggregateProjectPullUpConstantsRule(Aggregate.class,
            Filter.class, relBuilderFactory, "AggFilterPullUpConstants");
    this.projectMergeRule = new ProjectMergeRule(true, relBuilderFactory);
}
 
Example #12
Source File: FilterProjectTransposeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule.
 *
 * <p>Equivalent to the rule created by
 * {@link #FilterProjectTransposeRule(Class, Predicate, Class, Predicate, boolean, boolean, RelBuilderFactory)}
 * with some default predicates that do not allow a filter to be pushed
 * past the project if there is a correlation condition anywhere in the
 * filter (since in some cases it can prevent a
 * {@link org.apache.calcite.rel.core.Correlate} from being de-correlated).
 */
public FilterProjectTransposeRule(
    Class<? extends Filter> filterClass,
    Class<? extends Project> projectClass,
    boolean copyFilter, boolean copyProject,
    RelBuilderFactory relBuilderFactory) {
  this(filterClass,
      filter -> !RexUtil.containsCorrelation(filter.getCondition()),
      projectClass, project -> true,
      copyFilter, copyProject, relBuilderFactory);
}
 
Example #13
Source File: CompositeFilterJoinRule.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
protected RelNode doMatch(RelOptRuleCall call) {
  Filter filter = call.rel(0);
  Join join = call.rel(1);
  TransformCollectingCall c = new TransformCollectingCall(call.getPlanner(), this.getOperand(), new RelNode[] {filter, join}, null);
  perform(c, filter, join);
  if (c.outcome.isEmpty()) {
    return null;
  }

  return c.outcome.get(0);
}
 
Example #14
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
public FlinkFilterIntoJoinRule(boolean smart,
		RelBuilderFactory relBuilderFactory, Predicate predicate) {
	super(
			operand(Filter.class,
					operand(Join.class, RelOptRule.any())),
			"FlinkFilterJoinRule:filter", smart, relBuilderFactory,
			predicate);
}
 
Example #15
Source File: FilterMergeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
  final Filter topFilter = call.rel(0);
  final Filter bottomFilter = call.rel(1);

  // use RexPrograms to merge the two FilterRels into a single program
  // so we can convert the two LogicalFilter conditions to directly
  // reference the bottom LogicalFilter's child
  RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
  RexProgram bottomProgram = createProgram(bottomFilter);
  RexProgram topProgram = createProgram(topFilter);

  RexProgram mergedProgram =
      RexProgramBuilder.mergePrograms(
          topProgram,
          bottomProgram,
          rexBuilder);

  RexNode newCondition =
      mergedProgram.expandLocalRef(
          mergedProgram.getCondition());

  final RelBuilder relBuilder = call.builder();
  relBuilder.push(bottomFilter.getInput())
      .filter(newCondition);

  call.transformTo(relBuilder.build());
}
 
Example #16
Source File: FilterMergeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a RexProgram corresponding to a LogicalFilter
 *
 * @param filterRel the LogicalFilter
 * @return created RexProgram
 */
private RexProgram createProgram(Filter filterRel) {
  RexProgramBuilder programBuilder =
      new RexProgramBuilder(
          filterRel.getRowType(),
          filterRel.getCluster().getRexBuilder());
  programBuilder.addIdentity();
  programBuilder.addCondition(filterRel.getCondition());
  return programBuilder.getProgram();
}
 
Example #17
Source File: MaterializedViewRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Currently we only support TableScan - Project - Filter - Inner Join */
protected boolean isValidRelNodePlan(RelNode node, RelMetadataQuery mq) {
  final Multimap<Class<? extends RelNode>, RelNode> m =
          mq.getNodeTypes(node);
  if (m == null) {
    return false;
  }

  for (Entry<Class<? extends RelNode>, Collection<RelNode>> e : m.asMap().entrySet()) {
    Class<? extends RelNode> c = e.getKey();
    if (!TableScan.class.isAssignableFrom(c)
            && !Project.class.isAssignableFrom(c)
            && !Filter.class.isAssignableFrom(c)
            && (!Join.class.isAssignableFrom(c))) {
      // Skip it
      return false;
    }
    if (Join.class.isAssignableFrom(c)) {
      for (RelNode n : e.getValue()) {
        final Join join = (Join) n;
        if (join.getJoinType() != JoinRelType.INNER && !join.isSemiJoin()) {
          // Skip it
          return false;
        }
      }
    }
  }
  return true;
}
 
Example #18
Source File: FilterSetOpTransposeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
  Filter filterRel = call.rel(0);
  SetOp setOp = call.rel(1);

  RexNode condition = filterRel.getCondition();

  // create filters on top of each setop child, modifying the filter
  // condition to reference each setop child
  RexBuilder rexBuilder = filterRel.getCluster().getRexBuilder();
  final RelBuilder relBuilder = call.builder();
  List<RelDataTypeField> origFields =
      setOp.getRowType().getFieldList();
  int[] adjustments = new int[origFields.size()];
  final List<RelNode> newSetOpInputs = new ArrayList<>();
  for (RelNode input : setOp.getInputs()) {
    RexNode newCondition =
        condition.accept(
            new RelOptUtil.RexInputConverter(
                rexBuilder,
                origFields,
                input.getRowType().getFieldList(),
                adjustments));
    newSetOpInputs.add(relBuilder.push(input).filter(newCondition).build());
  }

  // create a new setop whose children are the filters created above
  SetOp newSetOp =
      setOp.copy(setOp.getTraitSet(), newSetOpInputs);

  call.transformTo(newSetOp);
}
 
Example #19
Source File: FilterCorrelateRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterCorrelateRule.
 */
public FilterCorrelateRule(RelBuilderFactory builderFactory) {
  super(
      operand(Filter.class,
          operand(Correlate.class, RelOptRule.any())),
      builderFactory, "FilterCorrelateRule");
}
 
Example #20
Source File: FilterMergeCrule.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a RexProgram corresponding to a LogicalFilter
 *
 * @param filterRel
 *          the LogicalFilter
 * @return created RexProgram
 */
private RexProgram createProgram(Filter filterRel) {
  RexProgramBuilder programBuilder = new RexProgramBuilder(filterRel.getRowType(),
      filterRel.getCluster().getRexBuilder());
  programBuilder.addIdentity();
  programBuilder.addCondition(filterRel.getCondition());
  return programBuilder.getProgram();
}
 
Example #21
Source File: FilterJoinRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Get conjunctions of filter's condition but with collapsed
 * {@code IS NOT DISTINCT FROM} expressions if needed.
 *
 * @param filter filter containing condition
 * @return condition conjunctions with collapsed {@code IS NOT DISTINCT FROM}
 * expressions if any
 * @see RelOptUtil#conjunctions(RexNode)
 */
private List<RexNode> getConjunctions(Filter filter) {
  List<RexNode> conjunctions = conjunctions(filter.getCondition());
  RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
  for (int i = 0; i < conjunctions.size(); i++) {
    RexNode node = conjunctions.get(i);
    if (node instanceof RexCall) {
      conjunctions.set(i,
          RelOptUtil.collapseExpandedIsNotDistinctFromExpr((RexCall) node, rexBuilder));
    }
  }
  return conjunctions;
}
 
Example #22
Source File: FilterAggregateTransposeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterAggregateTransposeRule.
 *
 * <p>If {@code filterFactory} is null, creates the same kind of filter as
 * matched in the rule. Similarly {@code aggregateFactory}.</p>
 */
public FilterAggregateTransposeRule(
    Class<? extends Filter> filterClass,
    RelBuilderFactory builderFactory,
    Class<? extends Aggregate> aggregateClass) {
  this(
      operand(filterClass,
          operand(aggregateClass, any())),
      builderFactory);
}
 
Example #23
Source File: FilterAggregateTransposeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Deprecated // to be removed before 2.0
public FilterAggregateTransposeRule(
    Class<? extends Filter> filterClass,
    RelFactories.FilterFactory filterFactory,
    Class<? extends Aggregate> aggregateClass) {
  this(filterClass, RelBuilder.proto(Contexts.of(filterFactory)),
      aggregateClass);
}
 
Example #24
Source File: RelFieldTrimmer.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Variant of {@link #trimFields(RelNode, ImmutableBitSet, Set)} for
 * {@link org.apache.calcite.rel.logical.LogicalFilter}.
 */
public TrimResult trimFields(Filter filter, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields) {
    final RelDataType rowType = filter.getRowType();
    final int fieldCount = rowType.getFieldCount();
    final RexNode conditionExpr = filter.getCondition();
    final RelNode input = filter.getInput();

    // We use the fields used by the consumer, plus any fields used in the
    // filter.
    final Set<RelDataTypeField> inputExtraFields = new LinkedHashSet<>(extraFields);
    RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder(inputExtraFields);
    inputFinder.inputBitSet.addAll(fieldsUsed);
    conditionExpr.accept(inputFinder);
    final ImmutableBitSet inputFieldsUsed = inputFinder.inputBitSet.build();

    // Create input with trimmed columns.
    TrimResult trimResult = trimChild(filter, input, inputFieldsUsed, inputExtraFields);
    RelNode newInput = trimResult.left;
    final Mapping inputMapping = trimResult.right;

    // If the input is unchanged, and we need to project all columns,
    // there's nothing we can do.
    if (newInput == input && fieldsUsed.cardinality() == fieldCount) {
        return result(filter, Mappings.createIdentity(fieldCount));
    }

    // Build new project expressions, and populate the mapping.
    final RexVisitor<RexNode> shuttle = new RexPermuteInputsShuttle(inputMapping, newInput);
    RexNode newConditionExpr = conditionExpr.accept(shuttle);

    // Use copy rather than relBuilder so that correlating variables get set.
    relBuilder.push(filter.copy(filter.getTraitSet(), newInput, newConditionExpr));

    // The result has the same mapping as the input gave us. Sometimes we
    // return fields that the consumer didn't ask for, because the filter
    // needs them for its condition.
    return result(relBuilder.build(), inputMapping);
}
 
Example #25
Source File: JdbcRules.java    From calcite with Apache License 2.0 5 votes vote down vote up
public RelNode convert(RelNode rel) {
  final Filter filter = (Filter) rel;

  return new JdbcFilter(
      rel.getCluster(),
      rel.getTraitSet().replace(out),
      convert(filter.getInput(),
          filter.getInput().getTraitSet().replace(out)),
      filter.getCondition());
}
 
Example #26
Source File: FilterProjectTransposeRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Deprecated // to be removed before 2.0
public FilterProjectTransposeRule(
    Class<? extends Filter> filterClass,
    RelFactories.FilterFactory filterFactory,
    Class<? extends Project> projectClass,
    RelFactories.ProjectFactory projectFactory) {
  this(filterClass, filter -> !RexUtil.containsCorrelation(filter.getCondition()),
      projectClass, project -> true,
      filterFactory == null,
      projectFactory == null,
      RelBuilder.proto(filterFactory, projectFactory));
}
 
Example #27
Source File: FilterRemoveIsNotDistinctFromRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
  Filter oldFilter = call.rel(0);
  RexNode oldFilterCond = oldFilter.getCondition();

  if (RexUtil.findOperatorCall(
      SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
      oldFilterCond)
      == null) {
    // no longer contains isNotDistinctFromOperator
    return;
  }

  // Now replace all the "a isNotDistinctFrom b"
  // with the RexNode given by RelOptUtil.isDistinctFrom() method

  RemoveIsNotDistinctFromRexShuttle rewriteShuttle =
      new RemoveIsNotDistinctFromRexShuttle(
          oldFilter.getCluster().getRexBuilder());

  final RelBuilder relBuilder = call.builder();
  final RelNode newFilterRel = relBuilder
      .push(oldFilter.getInput())
      .filter(oldFilterCond.accept(rewriteShuttle))
      .build();

  call.transformTo(newFilterRel);
}
 
Example #28
Source File: RelMdAllPredicates.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Add the Filter condition to the list obtained from the input.
 */
public RelOptPredicateList getAllPredicates(Filter filter, RelMetadataQuery mq) {
  final RelNode input = filter.getInput();
  final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
  final RexNode pred = filter.getCondition();

  final RelOptPredicateList predsBelow = mq.getAllPredicates(input);
  if (predsBelow == null) {
    // Safety check
    return null;
  }

  // Extract input fields referenced by Filter condition
  final Set<RelDataTypeField> inputExtraFields = new LinkedHashSet<>();
  final RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder(inputExtraFields);
  pred.accept(inputFinder);
  final ImmutableBitSet inputFieldsUsed = inputFinder.build();

  // Infer column origin expressions for given references
  final Map<RexInputRef, Set<RexNode>> mapping = new LinkedHashMap<>();
  for (int idx : inputFieldsUsed) {
    final RexInputRef ref = RexInputRef.of(idx, filter.getRowType().getFieldList());
    final Set<RexNode> originalExprs = mq.getExpressionLineage(filter, ref);
    if (originalExprs == null) {
      // Bail out
      return null;
    }
    mapping.put(ref, originalExprs);
  }

  // Replace with new expressions and return union of predicates
  final Set<RexNode> allExprs =
      RelMdExpressionLineage.createAllPossibleExpressions(rexBuilder, pred, mapping);
  if (allExprs == null) {
    return null;
  }
  return predsBelow.union(rexBuilder, RelOptPredicateList.of(rexBuilder, allExprs));
}
 
Example #29
Source File: DrillMergeFilterRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
    Filter topFilter = call.rel(0);
    Filter bottomFilter = call.rel(1);

    // use RexPrograms to merge the two FilterRels into a single program
    // so we can convert the two FilterRel conditions to directly
    // reference the bottom FilterRel's child
    RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
    RexProgram bottomProgram = createProgram(bottomFilter);
    RexProgram topProgram = createProgram(topFilter);

    RexProgram mergedProgram =
        RexProgramBuilder.mergePrograms(
            topProgram,
            bottomProgram,
            rexBuilder);

    RexNode newCondition =
        mergedProgram.expandLocalRef(
            mergedProgram.getCondition());

//    if(!RexUtil.isFlat(newCondition)){
//      RexCall newCall = (RexCall) newCondition;
//      newCondition = rexBuilder.makeFlatCall( newCall.getOperator(), newCall.getOperands());
//    }

    Filter newFilterRel =
        (Filter) filterFactory.createFilter(
            bottomFilter.getInput(),
            RexUtil.flatten(rexBuilder, newCondition));

    call.transformTo(newFilterRel);
  }
 
Example #30
Source File: FilterCorrelateRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterCorrelateRule.
 */
public FilterCorrelateRule(RelBuilderFactory builderFactory) {
  super(
      operand(Filter.class,
          operand(Correlate.class, RelOptRule.any())),
      builderFactory, "FilterCorrelateRule");
}