FAQ
"is null" syntax error with UDF and ternary operator
----------------------------------------------------

Key: PIG-2276
URL: https://issues.apache.org/jira/browse/PIG-2276
Project: Pig
Issue Type: Bug
Components: parser
Affects Versions: 0.9.0, 0.8.0
Environment: Debian Squeeze, Mac OS X 10.7.1, java 1.6.0_26,
Reporter: xavier


Applying "is null" to the result of a UDF inside the ternary operator gives a syntax error:

A = LOAD 'data.tsv' AS (a, b);
B = FOREACH A GENERATE ( parseNull(a) is null ? 1 : 0 );

gives the following error: Syntax error, unexpected symbol at or near 'parseNull'

The same error happens if parseNull is replaced by any other function, e.g. (TRIM(a) is null ? 1 : 0) will give the same error message.
However (a is null ? 1 : 0) and (parseNull(a) == '' ? 1 : 0) gets parsed without error, so it is related to the combination of "is null" and the result of a UDF.

Thanks,
X

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Search Discussions

  • Daniel Dai (Commented) (JIRA) at Oct 28, 2011 at 5:53 pm
    [ https://issues.apache.org/jira/browse/PIG-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13138591#comment-13138591 ]

    Daniel Dai commented on PIG-2276:
    ---------------------------------

    In grammar definition, we separate boolean expression (condition) and non-boolean (regular) expression. They cannot intermingle other than a few exception (bincond, eg). Filter only takes condition, and foreach only takes regular expression. It seems to be unnecessary as boolean is the first class data type in Pig now (PIG-1429). Some refactory of expression definition is needed.
    "is null" syntax error with UDF and ternary operator
    ----------------------------------------------------

    Key: PIG-2276
    URL: https://issues.apache.org/jira/browse/PIG-2276
    Project: Pig
    Issue Type: Bug
    Components: parser
    Affects Versions: 0.8.0, 0.9.0
    Environment: Debian Squeeze, Mac OS X 10.7.1, java 1.6.0_26,
    Reporter: xvrl

    Applying "is null" to the result of a UDF inside the ternary operator gives a syntax error:
    A = LOAD 'data.tsv' AS (a, b);
    B = FOREACH A GENERATE ( parseNull(a) is null ? 1 : 0 );
    gives the following error: Syntax error, unexpected symbol at or near 'parseNull'
    The same error happens if parseNull is replaced by any other function, e.g. (TRIM(a) is null ? 1 : 0) will give the same error message.
    However (a is null ? 1 : 0) and (parseNull(a) == '' ? 1 : 0) gets parsed without error, so it is related to the combination of "is null" and the result of a UDF.
    Thanks,
    X
    --
    This message is automatically generated by JIRA.
    If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
    For more information on JIRA, see: http://www.atlassian.com/software/jira

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriespig, hadoop
postedSep 9, '11 at 8:34p
activeOct 28, '11 at 5:53p
posts2
users1
websitepig.apache.org

1 user in discussion

Daniel Dai (Commented) (JIRA): 2 posts

People

Translate

site design / logo © 2022 Grokbase