GitHub user scwf opened a pull request:

    https://github.com/apache/spark/pull/2655

    [SPARK-3793][SQL]use hiveconf when parse hive ql

    This PR is to make hive ql parser more general and compatible with both 
hive-0.12 and hive-0.13. In hive-0.13 we may need hiveconf(or hivecontext) when 
parsing a sql(quoted sql). For example, when runing sql as follow without 
hiveconf will get NPE exception:
    
    createQueryTest("quoted alias.attr",
        "SELECT `a`.`key` FROM src a ORDER BY key LIMIT 1")
    [info] - quoted alias.attr *** FAILED ***
    [info]   org.apache.spark.sql.hive.HiveQl$ParseException: Failed to parse: 
SELECT `a`.`key` FROM src a ORDER BY key LIMIT 1
    [info]   at org.apache.spark.sql.hive.HiveQl$.parseSql(HiveQl.scala:221)
    [info]   at 
org.apache.spark.sql.hive.test.TestHiveContext$HiveQLQueryExecution.logical$lzycompute(TestHive.scala:143)
    [info]   at 
org.apache.spark.sql.hive.test.TestHiveContext$HiveQLQueryExecution.logical(TestHive.scala:143)
    [info]   at 
org.apache.spark.sql.hive.test.TestHiveContext$QueryExecution.analyzed$lzycompute(TestHive.scala:153)
    [info]   at 
org.apache.spark.sql.hive.test.TestHiveContext$QueryExecution.analyzed(TestHive.scala:152)
    [info]   at 
org.apache.spark.sql.SQLContext$QueryExecution.optimizedPlan$lzycompute(SQLContext.scala:403)
    [info]   at 
org.apache.spark.sql.SQLContext$QueryExecution.optimizedPlan(SQLContext.scala:403)
    [info]   at 
org.apache.spark.sql.SQLContext$QueryExecution.sparkPlan$lzycompute(SQLContext.scala:407)
    [info]   at 
org.apache.spark.sql.SQLContext$QueryExecution.sparkPlan(SQLContext.scala:405)
    [info]   at 
org.apache.spark.sql.SQLContext$QueryExecution.executedPlan$lzycompute(SQLContext.scala:411)
    [info]   ...
    [info]   Cause: java.lang.NullPointerException:
    [info]   at org.apache.hadoop.hive.conf.HiveConf.getVar(HiveConf.java:1295)
    [info]   at 
org.apache.hadoop.hive.ql.parse.HiveLexer.allowQuotedId(HiveLexer.java:342)
    [info]   at 
org.apache.hadoop.hive.ql.parse.HiveLexer$DFA21.specialStateTransition(HiveLexer.java:10945)
    [info]   at org.antlr.runtime.DFA.predict(DFA.java:80)
    [info]   at 
org.apache.hadoop.hive.ql.parse.HiveLexer.mIdentifier(HiveLexer.java:7925)
    [info]   at 
org.apache.hadoop.hive.ql.parse.HiveLexer.mTokens(HiveLexer.java:10818)
    [info]   at org.antlr.runtime.Lexer.nextToken(Lexer.java:89)
    [info]   at 
org.antlr.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:133)
    [info]   at 
org.antlr.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:127)
    [info]   at 
org.antlr.runtime.CommonTokenStream.consume(CommonTokenStream.java:70)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/scwf/spark addconf-to-hiveql

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/2655.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2655
    
----
commit 51e61621469392c3b357781230ef2909cf98b7a8
Author: scwf <[email protected]>
Date:   2014-10-04T15:09:18Z

    add hiveconf when parse hive ql

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to