use of org.apache.flink.table.functions.FunctionKind in project flink by apache.
the class FunctionCatalogOperatorTable method verifyFunctionKind.
/**
* Verifies which kinds of functions are allowed to be returned from the catalog given the
* context information.
*/
private boolean verifyFunctionKind(@Nullable SqlFunctionCategory category, ContextResolvedFunction resolvedFunction) {
final FunctionDefinition definition = resolvedFunction.getDefinition();
// built-in functions without implementation are handled separately
if (definition instanceof BuiltInFunctionDefinition) {
final BuiltInFunctionDefinition builtInFunction = (BuiltInFunctionDefinition) definition;
if (!builtInFunction.hasRuntimeImplementation()) {
return false;
}
}
final FunctionKind kind = definition.getKind();
if (kind == FunctionKind.TABLE) {
return true;
} else if (kind == FunctionKind.SCALAR || kind == FunctionKind.AGGREGATE || kind == FunctionKind.TABLE_AGGREGATE) {
if (category != null && category.isTableFunction()) {
throw new ValidationException(String.format("Function '%s' cannot be used as a table function.", resolvedFunction));
}
return true;
}
return false;
}
use of org.apache.flink.table.functions.FunctionKind in project flink by apache.
the class BridgingSqlAggFunction method of.
/**
* Creates an instance of a aggregating function (either a system or user-defined function).
*
* @param dataTypeFactory used for creating {@link DataType}
* @param typeFactory used for bridging to {@link RelDataType}
* @param kind commonly used SQL standard function; use {@link SqlKind#OTHER_FUNCTION} if this
* function cannot be mapped to a common function kind.
* @param resolvedFunction system or user-defined {@link FunctionDefinition} with context
* @param typeInference type inference logic
*/
public static BridgingSqlAggFunction of(DataTypeFactory dataTypeFactory, FlinkTypeFactory typeFactory, SqlKind kind, ContextResolvedFunction resolvedFunction, TypeInference typeInference) {
final FunctionKind functionKind = resolvedFunction.getDefinition().getKind();
checkState(functionKind == FunctionKind.AGGREGATE || functionKind == FunctionKind.TABLE_AGGREGATE, "Aggregating function kind expected.");
return new BridgingSqlAggFunction(dataTypeFactory, typeFactory, kind, resolvedFunction, typeInference);
}
use of org.apache.flink.table.functions.FunctionKind in project flink by apache.
the class BridgingSqlFunction method of.
/**
* Creates an instance of a scalar or table function (either a system or user-defined function).
*
* @param dataTypeFactory used for creating {@link DataType}
* @param typeFactory used for bridging to {@link RelDataType}
* @param kind commonly used SQL standard function; use {@link SqlKind#OTHER_FUNCTION} if this
* function cannot be mapped to a common function kind.
* @param resolvedFunction system or user-defined {@link FunctionDefinition} with context
* @param typeInference type inference logic
*/
public static BridgingSqlFunction of(DataTypeFactory dataTypeFactory, FlinkTypeFactory typeFactory, SqlKind kind, ContextResolvedFunction resolvedFunction, TypeInference typeInference) {
final FunctionKind functionKind = resolvedFunction.getDefinition().getKind();
checkState(functionKind == FunctionKind.SCALAR || functionKind == FunctionKind.TABLE, "Scalar or table function kind expected.");
return new BridgingSqlFunction(dataTypeFactory, typeFactory, kind, resolvedFunction, typeInference);
}
Aggregations