spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marmb...@apache.org
Subject spark git commit: [SPARK-7331] [SQL] Re-use HiveConf in HiveQl
Date Tue, 12 May 2015 02:04:18 GMT
Repository: spark
Updated Branches:
  refs/heads/branch-1.2 c0bd415bd -> d3b7a8b1d


[SPARK-7331] [SQL] Re-use HiveConf in HiveQl

Re-use HiveConf in HiveQl

Author: nitin2goyal <nitin2goyal@gmail.com>

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

7ff1f9e [nitin2goyal] [SPARK-7331][SQL] Re-use HiveConf in HiveQl


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/d3b7a8b1
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/d3b7a8b1
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/d3b7a8b1

Branch: refs/heads/branch-1.2
Commit: d3b7a8b1d031895d80a3f322ea2f5f94be663464
Parents: c0bd415
Author: nitin2goyal <nitin2goyal@gmail.com>
Authored: Mon May 11 19:04:15 2015 -0700
Committer: Michael Armbrust <michael@databricks.com>
Committed: Mon May 11 19:04:15 2015 -0700

----------------------------------------------------------------------
 .../main/scala/org/apache/spark/sql/hive/HiveQl.scala | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/d3b7a8b1/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
index 3d39e6c..a765617 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
@@ -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._
@@ -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)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message