RelDataType type = validator.deriveType(bb.scope, call); boolean distinct = false; SqlLiteral quantifier = call.getFunctionQuantifier();
/** * Iterates over all operands, derives their types, and collects them into * a list. */ public static List<RelDataType> deriveAndCollectTypes( SqlValidator validator, SqlValidatorScope scope, SqlNode [] operands) { // NOTE: Do not use an AbstractList. Don't want to be lazy. We want // errors. List<RelDataType> types = new ArrayList<RelDataType>(); for (SqlNode operand : operands) { types.add(validator.deriveType(scope, operand)); } return types; }
/** * Iterates over all operands, derives their types, and collects them into * a list. */ public static List<RelDataType> deriveAndCollectTypes( SqlValidator validator, SqlValidatorScope scope, List<SqlNode> operands) { // NOTE: Do not use an AbstractList. Don't want to be lazy. We want // errors. List<RelDataType> types = new ArrayList<RelDataType>(); for (SqlNode operand : operands) { types.add(validator.deriveType(scope, operand)); } return types; }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // special case for AS: never try to derive type for alias RelDataType nodeType = validator.deriveType(scope, call.operands[0]); assert nodeType != null; return validateOperands(validator, scope, call); }
public RelDataType getCursorOperand(int ordinal) { final SqlNode operand = call.operands[ordinal]; if (!SqlUtil.isCallTo(operand, SqlStdOperatorTable.cursorConstructor)) { return null; } final SqlCall cursorCall = (SqlCall) operand; final SqlNode query = cursorCall.operands[0]; return validator.deriveType(scope, query); }
/** * Validates this node in an expression context. * * <p>Usually, this method does much the same as {@link #validate}, but a * {@link SqlIdentifier} can occur in expression and non-expression * contexts. */ public void validateExpr( SqlValidator validator, SqlValidatorScope scope) { validate(validator, scope); Util.discard(validator.deriveType(scope, this)); }
public RelDataType getOperandType(int ordinal) { final SqlNode operand = call.operands[ordinal]; final RelDataType type = validator.deriveType(scope, operand); final SqlValidatorNamespace namespace = validator.getNamespace(operand); if (namespace != null) { return namespace.getRowTypeSansSystemColumns(); } return type; }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // special case for AS: never try to derive type for alias RelDataType nodeType = validator.deriveType(scope, call.operand(0)); assert nodeType != null; return validateOperands(validator, scope, call); }
/** * Validates this node in an expression context. * * <p>Usually, this method does much the same as {@link #validate}, but a * {@link SqlIdentifier} can occur in expression and non-expression * contexts. */ public void validateExpr( SqlValidator validator, SqlValidatorScope scope) { validate(validator, scope); Util.discard(validator.deriveType(scope, this)); }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // Override SqlFunction.deriveType, because function-resolution is // not relevant to a JDBC function call. // REVIEW: jhyde, 2006/4/18: Should SqlJdbcFunctionCall even be a // subclass of SqlFunction? for (SqlNode operand : call.operands) { RelDataType nodeType = validator.deriveType(scope, operand); validator.setValidatedNodeType(operand, nodeType); } return validateOperands(validator, scope, call); }
/** * Returns a string describing the actual argument types of a call, e.g. * "SUBSTR(VARCHAR(12), NUMBER(3,2), INTEGER)". */ protected String getCallSignature( SqlValidator validator, SqlValidatorScope scope) { List<String> signatureList = new ArrayList<String>(); for (final SqlNode operand : getOperandList()) { final RelDataType argType = validator.deriveType(scope, operand); if (null == argType) { continue; } signatureList.add(argType.toString()); } return SqlUtil.getOperatorSignature(getOperator(), signatureList); }
public RelDataType getOperandType(int ordinal) { final SqlNode operand = call.operand(ordinal); final RelDataType type = validator.deriveType(scope, operand); final SqlValidatorNamespace namespace = validator.getNamespace(operand); if (namespace != null) { return namespace.getType(); } return type; }
public RelDataType getCursorOperand(int ordinal) { final SqlNode operand = call.operand(ordinal); if (!SqlUtil.isCallTo(operand, SqlStdOperatorTable.CURSOR)) { return null; } final SqlCall cursorCall = (SqlCall) operand; final SqlNode query = cursorCall.operand(0); return validator.deriveType(scope, query); }
public RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // Override SqlFunction.deriveType, because function-resolution is // not relevant to a JDBC function call. // REVIEW: jhyde, 2006/4/18: Should SqlJdbcFunctionCall even be a // subclass of SqlFunction? for (SqlNode operand : call.getOperandList()) { RelDataType nodeType = validator.deriveType(scope, operand); validator.setValidatedNodeType(operand, nodeType); } return validateOperands(validator, scope, call); }
@Override public SqlMonotonicity getMonotonicity( SqlCall call, SqlValidatorScope scope) { RelDataTypeFamily castFrom = scope.getValidator().deriveType(scope, call.operands[0]) .getFamily(); RelDataTypeFamily castTo = scope.getValidator().deriveType(scope, call.operands[1]) .getFamily(); if (isMonotonicPreservingCast(castFrom, castTo)) { return call.operands[0].getMonotonicity(scope); } else { return SqlMonotonicity.NotMonotonic; } }
@Override public SqlMonotonicity getMonotonicity( SqlCall call, SqlValidatorScope scope) { RelDataTypeFamily castFrom = scope.getValidator().deriveType(scope, call.operand(0)).getFamily(); RelDataTypeFamily castTo = scope.getValidator().deriveType(scope, call.operand(1)).getFamily(); if (isMonotonicPreservingCast(castFrom, castTo)) { return call.operand(0).getMonotonicity(scope); } else { return SqlMonotonicity.NOT_MONOTONIC; } }
/** * Recreates a given RelDataType with nullability iff any of the operands * of a call are nullable. */ public static RelDataType makeNullableIfOperandsAre( final SqlValidator validator, final SqlValidatorScope scope, final SqlCall call, RelDataType type) { for (SqlNode operand : call.getOperandList()) { RelDataType operandType = validator.deriveType(scope, operand); if (containsNullable(operandType)) { RelDataTypeFactory typeFactory = validator.getTypeFactory(); type = typeFactory.createTypeWithNullability(type, true); break; } } return type; }
private boolean argTypesValid( SqlCallBinding callBinding) { if (callBinding.getOperandCount() < 2) { return true; // nothing to compare } SqlNode operand = callBinding.getCall().operands[0]; RelDataType firstType = callBinding.getValidator().deriveType( callBinding.getScope(), operand); for (int i = 1; i < callBinding.getCall().operands.length; i++) { operand = callBinding.getCall().operands[i]; RelDataType otherType = callBinding.getValidator().deriveType( callBinding.getScope(), operand); if (!SqlTypeUtil.sameNamedType(firstType, otherType)) { return false; } } return true; }
public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { for (int i = 0; i < callBinding.getOperandCount(); ++i) { RelDataType argType = callBinding.getValidator().deriveType( callBinding.getScope(), callBinding.getCall().operands[i]); if (!SqlTypeUtil.canAssignFrom(paramTypes[i], argType)) { if (throwOnFailure) { throw callBinding.newValidationSignatureError(); } else { return false; } } } return true; }
public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { final List<SqlNode> operands = callBinding.getCall().getOperandList(); for (Pair<RelDataType, SqlNode> pair : Pair.zip(paramTypes, operands)) { RelDataType argType = callBinding.getValidator().deriveType( callBinding.getScope(), pair.right); if (!SqlTypeUtil.canAssignFrom(pair.left, argType)) { if (throwOnFailure) { throw callBinding.newValidationSignatureError(); } else { return false; } } } return true; }