Skip to content

Commit

Permalink
[SPARK-7331] [SQL] Re-use HiveConf in HiveQl
Browse files Browse the repository at this point in the history
Re-use HiveConf in HiveQl

Author: nitin2goyal <[email protected]>

Closes #6036 from nitin2goyal/dev-nitin-1.2 and squashes the following commits:

7ff1f9e [nitin2goyal] [SPARK-7331][SQL] Re-use HiveConf in HiveQl
  • Loading branch information
nitin2goyal authored and marmbrus committed May 12, 2015
1 parent c0bd415 commit d3b7a8b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.apache.hadoop.hive.ql.lib.Node
import org.apache.hadoop.hive.ql.metadata.Table
import org.apache.hadoop.hive.ql.parse._
import org.apache.hadoop.hive.ql.plan.PlanUtils
import org.apache.hadoop.hive.ql.session.SessionState

import org.apache.spark.sql.catalyst.SparkSQLParser
import org.apache.spark.sql.catalyst.analysis._
Expand Down Expand Up @@ -224,12 +225,23 @@ private[hive] object HiveQl {
* Otherwise, there will be Null pointer exception,
* when retrieving properties form HiveConf.
*/
val hContext = new Context(new HiveConf())
val hContext = new Context(hiveConf)
val node = ParseUtils.findRootNonNullToken((new ParseDriver).parse(sql, hContext))
hContext.clear()
node
}

/**
* Returns the HiveConf
*/
private[this] def hiveConf(): HiveConf = {
val ss = SessionState.get() // SessionState is lazy initializaion, it can be null here
if (ss == null) {
new HiveConf()
} else {
ss.getConf
}
}

/** Returns a LogicalPlan for a given HiveQL string. */
def parseSql(sql: String): LogicalPlan = hqlParser(sql)
Expand Down

0 comments on commit d3b7a8b

Please sign in to comment.