Java Code Examples for org.apache.calcite.sql.validate.SqlValidator#removeValidatedNodeType()
The following examples show how to use
org.apache.calcite.sql.validate.SqlValidator#removeValidatedNodeType() .
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: SqlFunction.java From Bats with Apache License 2.0 | 4 votes |
private RelDataType deriveType( SqlValidator validator, SqlValidatorScope scope, SqlCall call, boolean convertRowArgToColumnList) { // Scope for operands. Usually the same as 'scope'. final SqlValidatorScope operandScope = scope.getOperandScope(call); // Indicate to the validator that we're validating a new function call validator.pushFunctionCall(); final List<String> argNames = constructArgNameList(call); final List<SqlNode> args = constructOperandList(validator, call, argNames); final List<RelDataType> argTypes = constructArgTypeList(validator, scope, call, args, convertRowArgToColumnList); final SqlFunction function = (SqlFunction) SqlUtil.lookupRoutine(validator.getOperatorTable(), getNameAsId(), argTypes, argNames, getFunctionType(), SqlSyntax.FUNCTION, getKind()); try { // if we have a match on function name and parameter count, but // couldn't find a function with a COLUMN_LIST type, retry, but // this time, don't convert the row argument to a COLUMN_LIST type; // if we did find a match, go back and re-validate the row operands // (corresponding to column references), now that we can set the // scope to that of the source cursor referenced by that ColumnList // type if (convertRowArgToColumnList && containsRowArg(args)) { if (function == null && SqlUtil.matchRoutinesByParameterCount( validator.getOperatorTable(), getNameAsId(), argTypes, getFunctionType())) { // remove the already validated node types corresponding to // row arguments before re-validating for (SqlNode operand : args) { if (operand.getKind() == SqlKind.ROW) { validator.removeValidatedNodeType(operand); } } return deriveType(validator, scope, call, false); } else if (function != null) { validator.validateColumnListParams(function, argTypes, args); } } if (getFunctionType() == SqlFunctionCategory.USER_DEFINED_CONSTRUCTOR) { return validator.deriveConstructorType(scope, call, this, function, argTypes); } if (function == null) { throw validator.handleUnresolvedFunction(call, this, argTypes, argNames); } // REVIEW jvs 25-Mar-2005: This is, in a sense, expanding // identifiers, but we ignore shouldExpandIdentifiers() // because otherwise later validation code will // choke on the unresolved function. ((SqlBasicCall) call).setOperator(function); return function.validateOperands( validator, operandScope, call); } finally { validator.popFunctionCall(); } }