Search code examples
apache-drill

No match found for function signature when NullHandling set to INTERNAL


I'm trying to implement an user defined function for Apache Drill.

The function takes float arguments (decimals do not work) and they have to be nullable in order to return zeroes.

However, when I use NullHandling.Internal and set the parameters as nullable types, the function can be no longer invoked.

SELECT tetsting_udf(1.23,4.56);

VALIDATION ERROR: (...): No match found for function signature TESTING_UDF(<DECIMAL>, <DECIMAL>)

SELECT tetsting_udf(cast(1.23 as float), cast(4.56 as float));

VALIDATION ERROR: (...): No match found for function signature TESTING_UDF(<FLOAT>, <FLOAT>)

When Float8Holders and NullHandling.NULL_IF_NULL is used, both calls above are working.

What I'm doing wrong?


@FunctionTemplate(
        name = "testing_udf",
        scope = FunctionTemplate.FunctionScope.SIMPLE,
        nulls = FunctionTemplate.NullHandling.INTERNAL
)
public class TestingFunction implements DrillSimpleFunc {

     @Param
         NullableFloat8Holder numberA;
     @Param
         NullableFloat8Holder numberB;
     @Output

     Float8Holder out;

     public void setup() {
     }

     public void eval() {
         // Whatever
     }
}

Solution

  • For the case when FunctionTemplate.NullHandling.INTERNAL is specified, UDFs implementations with all combinations of nullability should be specified. For your case, you should specify UDFs which accepts (Float8Holder and Float8Holder), (NullableFloat8Holder and NullableFloat8Holder), (Float8Holder and NullableFloat8Holder), (NullableFloat8Holder and Float8Holder).