use of org.apache.calcite.sql.SqlTableFunction in project flink by apache.
the class ProcedureNamespace method validateImpl.
public RelDataType validateImpl(RelDataType targetRowType) {
validator.inferUnknownTypes(validator.unknownType, scope, call);
final RelDataType type = validator.deriveTypeImpl(scope, call);
final SqlOperator operator = call.getOperator();
final SqlCallBinding callBinding = new SqlCallBinding(validator, scope, call);
if (operator instanceof SqlTableFunction) {
final SqlTableFunction tableFunction = (SqlTableFunction) operator;
if (type.getSqlTypeName() != SqlTypeName.CURSOR) {
throw new IllegalArgumentException("Table function should have CURSOR " + "type, not " + type);
}
final SqlReturnTypeInference rowTypeInference = tableFunction.getRowTypeInference();
RelDataType retType = rowTypeInference.inferReturnType(callBinding);
return validator.getTypeFactory().createTypeWithNullability(retType, false);
}
// special handling of collection tables TABLE(function(...))
if (SqlUtil.stripAs(enclosingNode).getKind() == SqlKind.COLLECTION_TABLE) {
return toStruct(type, getNode());
}
return type;
}
use of org.apache.calcite.sql.SqlTableFunction in project flink by apache.
the class SqlValidatorImpl method validateExpr.
/**
* Validates an expression.
*
* @param expr Expression
* @param scope Scope in which expression occurs
*/
private void validateExpr(SqlNode expr, SqlValidatorScope scope) {
if (expr instanceof SqlCall) {
final SqlOperator op = ((SqlCall) expr).getOperator();
if (op.isAggregator() && op.requiresOver()) {
throw newValidationError(expr, RESOURCE.absentOverClause());
}
if (op instanceof SqlTableFunction) {
throw RESOURCE.cannotCallTableFunctionHere(op.getName()).ex();
}
}
// Call on the expression to validate itself.
expr.validateExpr(this, scope);
// Perform any validation specific to the scope. For example, an
// aggregating scope requires that expressions are valid aggregations.
scope.validateExpr(expr);
}
Aggregations