You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by goun na <go...@gmail.com> on 2016/01/18 11:28:32 UTC

Grouping sets with table alias causes parse exception

Hi, Users

While converting legacy Oracle SQL to HiveQL using Grouping set, I found an
interesting parsing error. See the below example, Test-1 shows the expected
result, but Test-2 causes parting exception. Is it known issue?

Test-1> No table alias
select a.col_1, a.col_2
from
(
select '1' as col_1,'1' as  col_2
union all
select '2' as col_1, '2'as  col_2
) a
group by col_1, col_2 grouping sets (col_2, col_1);

----------------
NULL    1
NULL    2
1       NULL
2       NULL


Test-2>Table alias 'a.' is added at group by clause
select a.col_1, a.col_2
from
(
select '1' as col_1,'1' as  col_2
union all
select '2' as col_1, '2'as  col_2
) a
group by a.col_1, a.col_2 grouping sets ((a.col_1, a.col_2), a.col_1);



Error: Error while compiling statement: FAILED: ParseException line 1:162
missing ) at ',' near ')'
line 1:172 missing EOF at ',' near ')'

-- Error caused from HiveServer2



*org.apache.hive.service.cli.HiveSQLException:Error while compiling
statement: FAILED: ParseException line 1:162 missing ) at ',' near ')'
line 1:172 missing EOF at ',' near ')':28:27

Thanks,
Goun Na

Re: Grouping sets with table alias causes parse exception

Posted by goun na <go...@gmail.com>.
I found that it is already well described and fixed at Hive 1.2. Thanks!

Parsing Error in GROUPING SETS
https://issues.apache.org/jira/browse/HIVE-6950


2016-01-18 19:28 GMT+09:00 goun na <go...@gmail.com>:

> Hi, Users
>
> While converting legacy Oracle SQL to HiveQL using Grouping set, I found
> an interesting parsing error. See the below example, Test-1 shows the
> expected result, but Test-2 causes parting exception. Is it known issue?
>
> Test-1> No table alias
> select a.col_1, a.col_2
> from
> (
> select '1' as col_1,'1' as  col_2
> union all
> select '2' as col_1, '2'as  col_2
> ) a
> group by col_1, col_2 grouping sets (col_2, col_1);
>
> ----------------
> NULL    1
> NULL    2
> 1       NULL
> 2       NULL
>
>
> Test-2>Table alias 'a.' is added at group by clause
> select a.col_1, a.col_2
> from
> (
> select '1' as col_1,'1' as  col_2
> union all
> select '2' as col_1, '2'as  col_2
> ) a
> group by a.col_1, a.col_2 grouping sets ((a.col_1, a.col_2), a.col_1);
>
>
>
> Error: Error while compiling statement: FAILED: ParseException line 1:162
> missing ) at ',' near ')'
> line 1:172 missing EOF at ',' near ')'
>
> -- Error caused from HiveServer2
>
>
>
> *org.apache.hive.service.cli.HiveSQLException:Error while compiling
> statement: FAILED: ParseException line 1:162 missing ) at ',' near ')'
> line 1:172 missing EOF at ',' near ')':28:27
>
> Thanks,
> Goun Na
>