You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by Ashutosh Chauhan <ha...@apache.org> on 2014/09/11 01:58:23 UTC

Re: Review Request 25059: Ambiguous column reference error on query

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/25059/#review52982
-----------------------------------------------------------



ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
<https://reviews.apache.org/r/25059/#comment92287>

    I am bit confused here. Shouldn't this be if (tableAlias == null || tableAlias.equalsIgnoreCase(prev.getTabAlias()))
    
    Note missing !
    We want to throw an exception if tabAlias = null or if non-null than equal to prev. Isnt it?
    
    But, I see existing code is doing the same. So, confused here.


- Ashutosh Chauhan


On Aug. 26, 2014, 9:06 a.m., Navis Ryu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/25059/
> -----------------------------------------------------------
> 
> (Updated Aug. 26, 2014, 9:06 a.m.)
> 
> 
> Review request for hive.
> 
> 
> Bugs: HIVE-7733
>     https://issues.apache.org/jira/browse/HIVE-7733
> 
> 
> Repository: hive-git
> 
> 
> Description
> -------
> 
> {noformat}
> CREATE TABLE agg1 
>   ( 
>      col0 INT, 
>      col1 STRING, 
>      col2 DOUBLE 
>   ); 
> 
> explain SELECT single_use_subq11.a1 AS a1, 
>        single_use_subq11.a2 AS a2 
> FROM   (SELECT Sum(agg1.col2) AS a1 
>         FROM   agg1 
>         GROUP  BY agg1.col0) single_use_subq12 
>        JOIN (SELECT alias.a2 AS a0, 
>                     alias.a1 AS a1, 
>                     alias.a1 AS a2 
>              FROM   (SELECT agg1.col1 AS a0, 
>                             '42'      AS a1, 
>                             agg1.col0 AS a2 
>                      FROM   agg1 
>                      UNION ALL 
>                      SELECT agg1.col1 AS a0, 
>                             '41'      AS a1, 
>                             agg1.col0 AS a2 
>                      FROM   agg1) alias 
>              GROUP  BY alias.a2, 
>                        alias.a1) single_use_subq11 
>          ON ( single_use_subq11.a0 = single_use_subq11.a0 );
> {noformat}
> 
> Gets the following error:
> FAILED: SemanticException [Error 10007]: Ambiguous column reference a2
> Looks like this query had been working in 0.12 but starting failing with this error in 0.13
> 
> 
> Diffs
> -----
> 
>   ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java 33b8a21 
>   ql/src/test/queries/clientpositive/complex_alias.q PRE-CREATION 
>   ql/src/test/results/clientpositive/complex_alias.q.out PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/25059/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Navis Ryu
> 
>


Re: Review Request 25059: Ambiguous column reference error on query

Posted by Navis Ryu <na...@nexr.com>.

> On Sept. 10, 2014, 11:58 p.m., Ashutosh Chauhan wrote:
> > ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java, line 213
> > <https://reviews.apache.org/r/25059/diff/1/?file=669167#file669167line213>
> >
> >     I am bit confused here. Shouldn't this be if (tableAlias == null || tableAlias.equalsIgnoreCase(prev.getTabAlias()))
> >     
> >     Note missing !
> >     We want to throw an exception if tabAlias = null or if non-null than equal to prev. Isnt it?
> >     
> >     But, I see existing code is doing the same. So, confused here.

!tableAlias.equalsIgnoreCase(prev.getTabAlias()) means the column is from different table alias, which makes it an ambiguous alias. This can be done at last stage of processing the subquery. I'll update the patch.


- Navis


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/25059/#review52982
-----------------------------------------------------------


On Aug. 26, 2014, 9:06 a.m., Navis Ryu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/25059/
> -----------------------------------------------------------
> 
> (Updated Aug. 26, 2014, 9:06 a.m.)
> 
> 
> Review request for hive.
> 
> 
> Bugs: HIVE-7733
>     https://issues.apache.org/jira/browse/HIVE-7733
> 
> 
> Repository: hive-git
> 
> 
> Description
> -------
> 
> {noformat}
> CREATE TABLE agg1 
>   ( 
>      col0 INT, 
>      col1 STRING, 
>      col2 DOUBLE 
>   ); 
> 
> explain SELECT single_use_subq11.a1 AS a1, 
>        single_use_subq11.a2 AS a2 
> FROM   (SELECT Sum(agg1.col2) AS a1 
>         FROM   agg1 
>         GROUP  BY agg1.col0) single_use_subq12 
>        JOIN (SELECT alias.a2 AS a0, 
>                     alias.a1 AS a1, 
>                     alias.a1 AS a2 
>              FROM   (SELECT agg1.col1 AS a0, 
>                             '42'      AS a1, 
>                             agg1.col0 AS a2 
>                      FROM   agg1 
>                      UNION ALL 
>                      SELECT agg1.col1 AS a0, 
>                             '41'      AS a1, 
>                             agg1.col0 AS a2 
>                      FROM   agg1) alias 
>              GROUP  BY alias.a2, 
>                        alias.a1) single_use_subq11 
>          ON ( single_use_subq11.a0 = single_use_subq11.a0 );
> {noformat}
> 
> Gets the following error:
> FAILED: SemanticException [Error 10007]: Ambiguous column reference a2
> Looks like this query had been working in 0.12 but starting failing with this error in 0.13
> 
> 
> Diffs
> -----
> 
>   ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java 33b8a21 
>   ql/src/test/queries/clientpositive/complex_alias.q PRE-CREATION 
>   ql/src/test/results/clientpositive/complex_alias.q.out PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/25059/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Navis Ryu
> 
>