Java Code Examples for org.apache.calcite.sql.fun.SqlCastFunction

The following examples show how to use org.apache.calcite.sql.fun.SqlCastFunction. These examples are extracted from open source projects. 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 Project: Bats   Source File: RexImplicationChecker.java    License: Apache License 2.0 5 votes vote down vote up
private static RexNode removeCast(RexNode inputRef) {
  if (inputRef instanceof RexCall) {
    final RexCall castedRef = (RexCall) inputRef;
    final SqlOperator operator = castedRef.getOperator();
    if (operator instanceof SqlCastFunction) {
      inputRef = castedRef.getOperands().get(0);
    }
  }
  return inputRef;
}
 
Example 2
Source Project: Bats   Source File: VisitorDataContext.java    License: Apache License 2.0 5 votes vote down vote up
private static RexNode removeCast(RexNode inputRef) {
  if (inputRef instanceof RexCall) {
    final RexCall castedRef = (RexCall) inputRef;
    final SqlOperator operator = castedRef.getOperator();
    if (operator instanceof SqlCastFunction) {
      inputRef = castedRef.getOperands().get(0);
    }
  }
  return inputRef;
}
 
Example 3
@Override
public TupleExpression visitCall(RexCall call) {
    SqlOperator op = call.getOperator();
    if (op instanceof SqlCastFunction) {
        return call.getOperands().get(0).accept(this);
    } else if (op instanceof SqlUserDefinedFunction) {
        if (op.getName().equals("QUARTER")) {
            return visitFirstRexInputRef(call);
        }
    }

    TupleExpression tupleExpression;
    switch (op.getKind()) {
    case PLUS:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.PLUS);
        break;
    case MINUS:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.MINUS);
        break;
    case TIMES:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.MULTIPLE);
        break;
    case DIVIDE:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.DIVIDE);
        break;
    case CASE:
        tupleExpression = getCaseTupleExpression(call);
        break;
    default:
        tupleExpression = getRexCallTupleExpression(call);
    }
    if (ifVerify) {
        tupleExpression.verify();
    }
    return tupleExpression;
}
 
Example 4
Source Project: kylin   Source File: TupleExpressionVisitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TupleExpression visitCall(RexCall call) {
    SqlOperator op = call.getOperator();
    if (op instanceof SqlCastFunction) {
        return call.getOperands().get(0).accept(this);
    } else if (op instanceof SqlUserDefinedFunction) {
        if (op.getName().equals("QUARTER")) {
            return visitFirstRexInputRef(call);
        }
    }

    TupleExpression tupleExpression;
    switch (op.getKind()) {
    case PLUS:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.PLUS);
        break;
    case MINUS:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.MINUS);
        break;
    case TIMES:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.MULTIPLE);
        break;
    case DIVIDE:
        tupleExpression = getBinaryTupleExpression(call, TupleExpression.ExpressionOperatorEnum.DIVIDE);
        break;
    case CASE:
        tupleExpression = getCaseTupleExpression(call);
        break;
    default:
        tupleExpression = getRexCallTupleExpression(call);
    }
    if (ifVerify) {
        tupleExpression.verify();
    }
    return tupleExpression;
}