[ 
https://issues.apache.org/jira/browse/HIVE-1184?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul Yang updated HIVE-1184:
----------------------------

    Attachment: HIVE-1184.1.patch

The problem stems from DefaultExprProcessor:process(). During the AST walk, any 
error is cleared if a node matches a group by expression

{code}
...
      exprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx);
      if (desc != null) {
        ctx.setError(null);
        return desc;
      }
{code}

Clearing the error was probably an attempt to address the generation of false 
errors during the DFS walk of the AST. Consider the AST fragment from the query

{code}
SELECT concat(src.key) FROM src GROUP BY concat(src.key)

        TOK_FUNCTION
            / \
           /   \
          /     \
     concat      .
                / \ 
               /   \
TOK_TABLE_OR_COL    key
         |
         |
        src
{code}

During the walk, process() will be called on src before TOK_FUNCTION. Because 
src is not a group by expression, an error will be set in ctx. However, when 
process() is called on TOK_FUNCTION, it matches the group by expression 
'concat(src.key)' and the error is cleared, producing the expected behavior.

A problem arises with a query like

{code}
select concat(value, concat(value)) from src group by concat(value)
{code}

as the AST is such that 'value' (1st argument of outer concat) is processed 
before 'concat(value)'. When process() acts on 'value', it sets an error 
because it is not a group by expression. But then the error is cleared when 
process() is called on 'concat(value)'. The error should not really be cleared 
as it was generated outside of the group by expression.

The proposed solution is to keep track of the ASTNode that generated the error 
and only clear the error when it was generated from a node within the group by 
expression.

> Expression Not In Group By Key error is sometimes masked
> --------------------------------------------------------
>
>                 Key: HIVE-1184
>                 URL: https://issues.apache.org/jira/browse/HIVE-1184
>             Project: Hadoop Hive
>          Issue Type: Bug
>    Affects Versions: 0.6.0
>            Reporter: Paul Yang
>            Assignee: Paul Yang
>         Attachments: HIVE-1184.1.patch
>
>
> Depending on the order of expressions, the error message for a expression not 
> in group key is not displayed; instead it is null.
> {code}
> hive> select concat(value, concat(value)) from src group by concat(value);
> FAILED: Error in semantic analysis: null
> hive> select concat(concat(value), value) from src group by concat(value);
> FAILED: Error in semantic analysis: line 1:29 Expression Not In Group By Key 
> value
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to