You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Xuefu Zhang (JIRA)" <ji...@apache.org> on 2014/12/16 05:05:13 UTC

[jira] [Comment Edited] (HIVE-9113) Explain on query failed with NPE

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

Xuefu Zhang edited comment on HIVE-9113 at 12/16/14 4:04 AM:
-------------------------------------------------------------

The correct syntax for subquery in from clause is:
{code}
select col_list from (subquery) as alias;
{code}
For example, the following query works for me:
{code}
select name from (select name, value from dec) as A;
{code}
If I miss "as A", then I got some exception other than NPE:
{code}
select name from (select name, value from dec);
NoViableAltException(-1@[207:51: ( KW_AS )?])
	at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)
...
{code}
Your query is more complicated, but in either case, we should get meaningful error messages instead of exceptions.



was (Author: xuefuz):
The correct syntax for subquery in from clause is:
{code}
select col_list from (subquery) as alias;
{code}.
For example, the following query works for me:
{code}
select name from (select name, value from dec) as A;
{code}
If I miss "as A", then I got some exception other than NPE:
{code}
select name from (select name, value from dec);
NoViableAltException(-1@[207:51: ( KW_AS )?])
	at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)
...
{code}
Your query is more complicated, but in either case, we should get meaningful error messages instead of exceptions.


> Explain on query failed with NPE
> --------------------------------
>
>                 Key: HIVE-9113
>                 URL: https://issues.apache.org/jira/browse/HIVE-9113
>             Project: Hive
>          Issue Type: Bug
>          Components: Query Processor
>            Reporter: Chao
>
> Run explain on the following query:
> {noformat}
> select p.p_partkey, li.l_suppkey
> from (select distinct l_partkey as p_partkey from lineitem) p join lineitem li on p.p_partkey = li.l_partkey
> where li.l_linenumber = 1 and
>  li.l_orderkey in (select l_orderkey where l_linenumber = li.l_linenumber)
> ;
> {noformat}
> gave me NPE:
> {noformat}
> java.lang.NullPointerException
>   at org.apache.hadoop.hive.ql.parse.QBSubQuery.validateAndRewriteAST(QBSubQuery.java:516)
>   at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genFilterPlan(SemanticAnalyzer.java:2605)
>   at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genBodyPlan(SemanticAnalyzer.java:8866)
>   at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:9745)
>   at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:9638)
>   at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:10125)
>   at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:221)
>   at org.apache.hadoop.hive.ql.parse.ExplainSemanticAnalyzer.analyzeInternal(ExplainSemanticAnalyzer.java:74)
>   at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:221)
>   at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:420)
>   at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:306)
>   at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1108)
>   at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1170)
>   at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1045)
>   at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1035)
>   at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:199)
>   at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:151)
>   at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:362)
>   at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:720)
>   at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:639)
>   at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:578)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:606)
>   at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
> {noformat}
> Is this query invalid? If so, it should at least give some explanations, not just a plain NPE message, and left user clueless.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)