You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "James Taylor (JIRA)" <ji...@apache.org> on 2018/03/07 17:06:00 UTC

[jira] [Commented] (PHOENIX-4639) Udf's don't run execute method when using null as a parameter.

    [ https://issues.apache.org/jira/browse/PHOENIX-4639?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16389807#comment-16389807 ] 

James Taylor commented on PHOENIX-4639:
---------------------------------------

I'm curious why you can't just use the built-in {{IS NULL}} syntax? There are optimizations around this in terms of setting the scan range as well as some special cases (for example that on filtering you need to evaluate the expression after you've seen all the cells for a given row determined by Expression.requiresFinalEvaluation() returning true). Trying to emulate all this with your own UDF will be difficult.

The particular behavior you're seeing is defined by the FunctionParseNode.evalToNullIfParamIsNull(StatementContext context, int index) method. Typically, if an argument is null, the function evaluates to null. You can override this by defining your own nodeClassName with an override for this method (see my patch on PHOENIX-4644 for an example). I don't think this is possible with a UDF, though. Probably best to override UDFParseNode#evalToNullIfParamIsNull to return false. Please file a JIRA.

> Udf's don't run execute method when using null as a parameter.
> --------------------------------------------------------------
>
>                 Key: PHOENIX-4639
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4639
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.13.2-cdh5.11.2
>         Environment: Centos 7  using Cloudera
>            Reporter: Clive Stellings
>            Priority: Major
>         Attachments: IsNull.java
>
>
> When attempting to use a UDF the code for evaluate never runs if the parameter for the UDF is null.  I wrote a function called isnull that is attempting to emulate the same function as in Mysql but when I enter null e.g. isnull(null) it returns with an empty value and when I check if the evaluate method actually runs, it never enters the method.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)