[
https://issues.apache.org/jira/browse/PIG-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13692967#comment-13692967
]
Cheolsoo Park edited comment on PIG-3364 at 6/25/13 12:20 PM:
--------------------------------------------------------------
This is really one-line change:
{code}
- boolean hasElse = exprs.size() \% 2 == 1;
+ boolean hasElse = exprs.size() != conds.size();
{code}
The exprs and conds are lists of LogicalExpressions in case statement (i.e.
WHEN cond THEN expr ELSE expr).
The reason why this was not caught by the unit tests was because I only tested
an odd number of when branches. So I also update the unit tests. Now they test
1) an even number of when branches w/ else, and 2) an odd number of when
branches w/o else.
was (Author: cheolsoo):
This is really one-line change:
{code}
- boolean hasElse = exprs.size() \% 2 == 1;
+ boolean hasElse = exprs.size() != conds.size();
{code}
The exprs and conds are lists of LogicalExpressions in case statement (i.e.
WHEN cond THEN expr ELSE expr).
The reason why this was not caught by the unit tests was because I only tested
an odd number of when branches. So I also update the unit tests.
> Case expression fails with an even number of when branches
> ----------------------------------------------------------
>
> Key: PIG-3364
> URL: https://issues.apache.org/jira/browse/PIG-3364
> Project: Pig
> Issue Type: Bug
> Components: parser
> Reporter: Cheolsoo Park
> Assignee: Cheolsoo Park
> Fix For: 0.12
>
> Attachments: PIG-3364.patch
>
>
> This is a bug introduced by PIG-3342 - Allow conditions in case statement.
> If 1) there are an even number of when branches, and 2) there is the else
> branch, case statement with conditions fails with the following error:
> {code}
> Caused by: org.apache.pig.impl.logicalLayer.validators.TypeCheckerException:
> ERROR 1057:
> <line 2, column 14> LOGenerate expression plan can only have one output
> {code}
> This is because the logic of determining whether case statement has the else
> branch is incorrect. This doesn't happen when conditions are not used in case
> statement.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira