Search in sources :

Example 1 with ScalarFunction

use of org.apache.flink.table.functions.ScalarFunction in project flink by apache.

the class LegacyScalarFunctionConvertRule method convert.

@Override
public Optional<RexNode> convert(CallExpression call, ConvertContext context) {
    FunctionDefinition def = call.getFunctionDefinition();
    if (def instanceof ScalarFunctionDefinition) {
        ScalarFunction scalaFunc = ((ScalarFunctionDefinition) def).getScalarFunction();
        FunctionIdentifier identifier = call.getFunctionIdentifier().orElse(FunctionIdentifier.of(generateInlineFunctionName(scalaFunc)));
        SqlFunction sqlFunction = UserDefinedFunctionUtils.createScalarSqlFunction(identifier, scalaFunc.toString(), scalaFunc, context.getTypeFactory());
        return Optional.of(context.getRelBuilder().call(sqlFunction, toRexNodes(context, call.getChildren())));
    }
    return Optional.empty();
}
Also used : FunctionIdentifier(org.apache.flink.table.functions.FunctionIdentifier) ScalarFunctionDefinition(org.apache.flink.table.functions.ScalarFunctionDefinition) ScalarFunction(org.apache.flink.table.functions.ScalarFunction) ScalarFunctionDefinition(org.apache.flink.table.functions.ScalarFunctionDefinition) FunctionDefinition(org.apache.flink.table.functions.FunctionDefinition) SqlFunction(org.apache.calcite.sql.SqlFunction)

Aggregations

SqlFunction (org.apache.calcite.sql.SqlFunction)1 FunctionDefinition (org.apache.flink.table.functions.FunctionDefinition)1 FunctionIdentifier (org.apache.flink.table.functions.FunctionIdentifier)1 ScalarFunction (org.apache.flink.table.functions.ScalarFunction)1 ScalarFunctionDefinition (org.apache.flink.table.functions.ScalarFunctionDefinition)1