Search in sources :

Example 1 with Function

use of org.apache.calcite.schema.Function in project storm by apache.

the class StormSqlImpl method handleCreateFunction.

private void handleCreateFunction(SqlCreateFunction sqlCreateFunction) throws ClassNotFoundException {
    if (sqlCreateFunction.jarName() != null) {
        throw new UnsupportedOperationException("UDF 'USING JAR' not implemented");
    }
    Method method;
    Function function;
    if ((method = findMethod(sqlCreateFunction.className(), "evaluate")) != null) {
        function = ScalarFunctionImpl.create(method);
    } else if (findMethod(sqlCreateFunction.className(), "add") != null) {
        function = AggregateFunctionImpl.create(Class.forName(sqlCreateFunction.className()));
    } else {
        throw new RuntimeException("Invalid scalar or aggregate function");
    }
    schema.add(sqlCreateFunction.functionName().toUpperCase(), function);
    hasUdf = true;
}
Also used : Function(org.apache.calcite.schema.Function) SqlCreateFunction(org.apache.storm.sql.parser.SqlCreateFunction) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 Function (org.apache.calcite.schema.Function)1 SqlCreateFunction (org.apache.storm.sql.parser.SqlCreateFunction)1