[ https://issues.apache.org/jira/browse/DRILL-7677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17070949#comment-17070949 ]
Charles Givre commented on DRILL-7677: -------------------------------------- [~nielsbasjes] I think you've uncovered a gripe of mine with how Drill handles UDFs that have a complex field as output. A normal UDF you can specify the null handling and then you can safely assume that the data the function receives is not null. However, in the case of UDFs which output complex fields, it is necessary to have two versions: one that has a non-nullable holder as input, that actually returns the correct output and a second that has a nullable holder as input and returns an empty list or map as output. In any event, there are unit tests for this function [1] that include tests for null values. [1]: https://github.com/apache/drill/blob/master/contrib/udfs/src/test/java/org/apache/drill/exec/udfs/TestUserAgentFunctions.java > NPE in getStringFromVarCharHolder(NullableVarCharHolder) > --------------------------------------------------------- > > Key: DRILL-7677 > URL: https://issues.apache.org/jira/browse/DRILL-7677 > Project: Apache Drill > Issue Type: Bug > Reporter: Niels Basjes > Priority: Major > > Assume you have a function ([like this > one|https://github.com/apache/drill/blob/master/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/UserAgentFunctions.java#L110]) > that has > {code:java} > @Param > NullableVarCharHolder input; > {code} > and in the {code:java}eval(){code} function you do > {code:java}String inputString = > org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getStringFromVarCharHolder(input);{code} > When this function is called with the input actually being null the 'input' > parameter is an instance of NullableVarCharHolder where isSet is 0 and buffer > is null. > The buffer being null causes an NPE in the call to > getStringFromVarCharHolder(NullableVarCharHolder) -- This message was sent by Atlassian Jira (v8.3.4#803005)