[ 
https://issues.apache.org/jira/browse/HIVE-2747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13802729#comment-13802729
 ] 

jeff little commented on HIVE-2747:
-----------------------------------

Hi, Kevin Wilfong.
You can try the hql: "from (select key, value, cast( count(1) as int) count 
from src group by key, value union all select NULL as key, value,cast( count(1) 
as int) count from src group by value) a select count;". You should modify the 
data type of ’count‘, otherwise the data type of  'count' in the  intermediate 
result  is void type, so it will cause "java.lang.NullPointerException". In 
addition, if the hql sentences have union all operator, you should use 'AS' as 
the column's alias.

> 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
>
> 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 was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to