Search in sources :

Example 1 with CallContext

use of org.apache.flink.table.types.inference.CallContext in project flink by apache.

the class HiveSimpleUDFTest method init.

protected static HiveSimpleUDF init(Class hiveUdfClass, DataType[] argTypes) {
    HiveSimpleUDF udf = new HiveSimpleUDF(new HiveFunctionWrapper(hiveUdfClass.getName()), hiveShim);
    // Hive UDF won't have literal args
    CallContext callContext = new HiveUDFCallContext(new Object[0], argTypes);
    udf.getTypeInference(null).getOutputTypeStrategy().inferType(callContext);
    udf.open(null);
    return udf;
}
Also used : CallContext(org.apache.flink.table.types.inference.CallContext)

Example 2 with CallContext

use of org.apache.flink.table.types.inference.CallContext 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 3 with CallContext

use of org.apache.flink.table.types.inference.CallContext 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)

Example 4 with CallContext

use of org.apache.flink.table.types.inference.CallContext in project flink by apache.

the class TypeInferenceOperandChecker method checkOperandTypesOrError.

// --------------------------------------------------------------------------------------------
private boolean checkOperandTypesOrError(SqlCallBinding callBinding, CallContext callContext) {
    final CallContext adaptedCallContext;
    try {
        adaptedCallContext = adaptArguments(typeInference, callContext, null);
    } catch (ValidationException e) {
        throw createInvalidInputException(typeInference, callContext, e);
    }
    insertImplicitCasts(callBinding, adaptedCallContext.getArgumentDataTypes());
    return true;
}
Also used : ValidationException(org.apache.flink.table.api.ValidationException) CallContext(org.apache.flink.table.types.inference.CallContext)

Aggregations

CallContext (org.apache.flink.table.types.inference.CallContext)4 HiveUDFCallContext (org.apache.flink.table.functions.hive.HiveSimpleUDFTest.HiveUDFCallContext)2 ValidationException (org.apache.flink.table.api.ValidationException)1 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