[ https://issues.apache.org/jira/browse/HIVE-2747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199099#comment-13199099 ]
Namit Jain commented on HIVE-2747: ---------------------------------- create table tmp_tx1 (key string, value string); insert overwrite table tmp_tx1 select * from src where key < 10; create table tmp_tx2 (key int, value string); insert overwrite table tmp_tx2 select * from src where key < 10; select * from ( select key, count(1) from tmp_tx1 group by key union all select key, count(1) from tmp_tx2 group by key ) u; The above also fails. Basically, if the types of the union dont match, we get a run-time error. The query: select * from ( select key, count(1) from tmp_tx1 group by key union all select cast(key as string) as key, count(1) from tmp_tx2 group by key ) u; works fine > UNION ALL with subquery which selects NULL and performs group by fails > ---------------------------------------------------------------------- > > Key: HIVE-2747 > URL: https://issues.apache.org/jira/browse/HIVE-2747 > Project: Hive > Issue Type: Bug > Reporter: Kevin Wilfong > Assignee: Kevin Wilfong > > Queries like the following > from (select key, value, count(1) as count from src group by key, value union > all select NULL as key, value, count(1) as count from src group by value) a > select count(*); > fail with the exception > java.lang.NullPointerException > at > org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector.toString(StructObjectInspector.java:60) > at java.lang.String.valueOf(String.java:2826) > at java.lang.StringBuilder.append(StringBuilder.java:115) > at > org.apache.hadoop.hive.ql.exec.UnionOperator.initializeOp(UnionOperator.java:110) > at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:357) > at > org.apache.hadoop.hive.ql.exec.MapOperator.initializeOp(MapOperator.java:427) > at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:357) > at org.apache.hadoop.hive.ql.exec.ExecMapper.configure(ExecMapper.java:98) > ... 18 more > This should at least provide a more informative error message if not work. > It works without the group by. -- 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