public void inferOperandTypes( SqlCallBinding callBinding, RelDataType returnType, RelDataType[] operandTypes) { final RelDataType unknownType = callBinding.getValidator().getUnknownType(); RelDataType knownType = unknownType; for (int i = 1; i < callBinding.getCall().getOperandList().size(); i++) { SqlNode operand = callBinding.getCall().getOperandList().get(i); knownType = callBinding.getValidator().deriveType( callBinding.getScope(), operand); if (!knownType.equals(unknownType)) { break; } } RelDataTypeFactory typeFactory = callBinding.getTypeFactory(); operandTypes[0] = typeFactory.createSqlType(SqlTypeName.BOOLEAN); for (int i = 1; i < operandTypes.length; ++i) { operandTypes[i] = knownType; } } };
public void inferOperandTypes( SqlCallBinding callBinding, RelDataType returnType, RelDataType[] operandTypes) { final RelDataType unknownType = callBinding.getValidator().getUnknownType(); RelDataType knownType = unknownType; for (int i = 1; i < callBinding.getCall().getOperandList().size(); i++) { SqlNode operand = callBinding.getCall().getOperandList().get(i); knownType = callBinding.getValidator().deriveType( callBinding.getScope(), operand); if (!knownType.equals(unknownType)) { break; } } RelDataTypeFactory typeFactory = callBinding.getTypeFactory(); operandTypes[0] = typeFactory.createSqlType(SqlTypeName.BOOLEAN); for (int i = 1; i < operandTypes.length; ++i) { operandTypes[i] = knownType; } } };
/** Registers with the validator a {@link SqlNode} that has been created * during the Sql-to-Rel process. */ private static SqlNode reg(SqlValidatorScope scope, SqlNode e) { scope.getValidator().deriveType(scope, e); return e; }
/** Registers with the validator a {@link SqlNode} that has been created * during the Sql-to-Rel process. */ private static SqlNode reg(SqlValidatorScope scope, SqlNode e) { scope.getValidator().deriveType(scope, e); return e; }
/** Registers with the validator a {@link SqlNode} that has been created * during the Sql-to-Rel process. */ private static SqlNode reg(SqlValidatorScope scope, SqlNode e) { scope.getValidator().deriveType(scope, e); return e; }
/** Registers with the validator a {@link SqlNode} that has been created * during the Sql-to-Rel process. */ private static SqlNode reg(SqlValidatorScope scope, SqlNode e) { scope.getValidator().deriveType(scope, e); return e; }
/** * 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) { // 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); }
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)); }
@Override 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); }
@Override public RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // To prevent operator rewriting by SqlFunction#deriveType. for (SqlNode operand : call.getOperandList()) { RelDataType nodeType = validator.deriveType(scope, operand); ((SqlValidatorImpl) 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<>(); 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); }
@Override 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; }
@Override 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; }
@Override 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); }
@Override public RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call) { // To prevent operator rewriting by SqlFunction#deriveType. for (SqlNode operand : call.getOperandList()) { RelDataType nodeType = validator.deriveType(scope, operand); ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType); } return validateOperands(validator, scope, call); }
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); ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType); } return validateOperands(validator, scope, call); }
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); ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType); } return validateOperands(validator, scope, call); }
@Override public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { final SqlNode left = callBinding.operand(0); final SqlNode right = callBinding.operand(1); final RelDataType type = callBinding.getValidator().deriveType(callBinding.getScope(), left); if (type.getSqlTypeName() != SqlTypeName.ROW) { return false; } final RelDataType operandType = callBinding.getOperandType(0); final SqlSingleOperandTypeChecker checker = getChecker(operandType); return checker.checkSingleOperandType(callBinding, right, 0, throwOnFailure); }