Java Code Examples for org.apache.calcite.rex.RexUtil#findOperatorCall()

The following examples show how to use org.apache.calcite.rex.RexUtil#findOperatorCall() . 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: FilterRemoveIsNotDistinctFromRule.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Override
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 2
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);
}