Search in sources :

Example 1 with HiveUDFCallContext

use of org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext in project flink by apache.

the class HiveGenericUDFTest method init.

private static HiveGenericUDF init(Class hiveUdfClass, Object[] constantArgs, DataType[] argTypes) {
    HiveGenericUDF udf = new HiveGenericUDF(new HiveFunctionWrapper(hiveUdfClass.getName()), hiveShim);
    CallContext callContext = new HiveUDFCallContext(constantArgs, argTypes);
    udf.getTypeInference(null).getOutputTypeStrategy().inferType(callContext);
    udf.open(null);
    return udf;
}
Also used : HiveUDFCallContext(org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext) HiveUDFCallContext(org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext) CallContext(org.apache.flink.table.types.inference.CallContext)

Example 2 with HiveUDFCallContext

use of org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext in project flink by apache.

the class HiveModuleTest method testHiveBuiltInFunction.

@Test
public void testHiveBuiltInFunction() {
    FunctionDefinition fd = new HiveModule().getFunctionDefinition("reverse").get();
    HiveSimpleUDF udf = (HiveSimpleUDF) fd;
    DataType[] inputType = new DataType[] { DataTypes.STRING() };
    CallContext callContext = new HiveUDFCallContext(new Object[0], inputType);
    udf.getTypeInference(null).getOutputTypeStrategy().inferType(callContext);
    udf.open(null);
    assertEquals("cba", udf.eval("abc"));
}
Also used : HiveSimpleUDF(org.apache.flink.table.functions.hive.HiveSimpleUDF) DataType(org.apache.flink.table.types.DataType) FunctionDefinition(org.apache.flink.table.functions.FunctionDefinition) HiveUDFCallContext(org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext) HiveUDFCallContext(org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext) CallContext(org.apache.flink.table.types.inference.CallContext) Test(org.junit.Test)

Aggregations

HiveUDFCallContext (org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext)2 CallContext (org.apache.flink.table.types.inference.CallContext)2 FunctionDefinition (org.apache.flink.table.functions.FunctionDefinition)1 HiveSimpleUDF (org.apache.flink.table.functions.hive.HiveSimpleUDF)1 DataType (org.apache.flink.table.types.DataType)1 Test (org.junit.Test)1