Java Code Examples for org.apache.calcite.sql.SqlKind#NOT

The following examples show how to use org.apache.calcite.sql.SqlKind#NOT . 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: PredicateAnalyzer.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@Override
public RexNode visitCall(RexCall call) {
  if (call.getOperator().getKind() == SqlKind.NOT) {
    RexNode child = call.getOperands().get(0);
    if (child.getKind() == SqlKind.LIKE) {
      List<RexNode> operands = FluentIterable.from(((RexCall) child).getOperands()).transform(new Function<RexNode, RexNode>() {
        @Override
        public RexNode apply(RexNode rexNode) {
          return rexNode.accept(NotLikeConverter.this);
        }
      }).toList();
      return rexBuilder.makeCall(SqlStdOperatorTable.NOT_LIKE, operands);
    }
  }
  return super.visitCall(call);
}
 
Example 2
Source File: RexUtil.java    From Bats with Apache License 2.0 5 votes vote down vote up
/** Applies NOT to an expression. */
static RexNode not(final RexBuilder rexBuilder, RexNode input) {
    return input.isAlwaysTrue() ? rexBuilder.makeLiteral(false)
            : input.isAlwaysFalse() ? rexBuilder.makeLiteral(true)
                    : input.getKind() == SqlKind.NOT ? ((RexCall) input).getOperands().get(0)
                            : rexBuilder.makeCall(SqlStdOperatorTable.NOT, input);
}
 
Example 3
Source File: FindPartitionConditions.java    From Bats with Apache License 2.0 5 votes vote down vote up
private void popOpStackAndBuildFilter() {
  // Parsing a special expression; handled holistically by the parent
  if (holisticExpression > 0) {
    return;
  }
  OpState currentOp = opStack.pop();
  int size = currentOp.getChildren().size();
  RexNode newFilter = null;
  if (size >= 1) {
    if (size == 1 && currentOp.getOp() instanceof SqlBinaryOperator) {
      /* The only operator for which we allow partial pushes is AND.
       * For all other operators we clear the children if one of the
       * children is a no push.
       */
      if (currentOp.getOp().getKind() == SqlKind.AND) {
        newFilter = currentOp.getChildren().get(0);
        for (OpState opState : opStack) {
          if (opState.getOp().getKind() == SqlKind.NOT) {
            //AND under NOT should not get pushed
            newFilter = null;
          }
        }

      }
    } else {
      newFilter = builder.makeCall(currentOp.getOp(), currentOp.getChildren());
    }
  }

  if (newFilter != null) {
    // add this new filter to my parent boolean operator's children
    if (!opStack.isEmpty()) {
      OpState parentOp = opStack.peek();
      parentOp.addChild(newFilter);
    } else {
      resultCondition = newFilter;
    }
  }
}
 
Example 4
Source File: PredicateAnalyzer.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public RexNode visitCall(RexCall call) {
  if (call.getOperator().getKind() == SqlKind.NOT) {
    RexNode child = call.getOperands().get(0);
    if (child.getKind() == SqlKind.LIKE) {
      return rexBuilder.makeCall(SqlStdOperatorTable.NOT_LIKE,
          visitList(((RexCall) child).getOperands()));
    }
  }
  return super.visitCall(call);
}
 
Example 5
Source File: RexUtil.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Applies NOT to an expression. */
static RexNode not(final RexBuilder rexBuilder, RexNode input) {
  return input.isAlwaysTrue()
      ? rexBuilder.makeLiteral(false)
      : input.isAlwaysFalse()
      ? rexBuilder.makeLiteral(true)
      : input.getKind() == SqlKind.NOT
      ? ((RexCall) input).operands.get(0)
      : rexBuilder.makeCall(SqlStdOperatorTable.NOT, input);
}