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

The following examples show how to use org.apache.calcite.sql.fun.SqlCastFunction. 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: RexImplicationChecker.java    From Bats with 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 File: VisitorDataContext.java    From Bats with 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
Source File: TupleExpressionVisitor.java    From kylin-on-parquet-v2 with 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;
}
 
Example #4
Source File: TupleExpressionVisitor.java    From kylin with 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;
}