Skip to content

Commit a3b7793

Browse files
committed
Set sessionState when dealing with CreateTableAsSelect.
1 parent 61073f8 commit a3b7793

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.apache.hadoop.hive.metastore.{Warehouse, TableType}
2727
import org.apache.hadoop.hive.metastore.api.{Table => TTable, Partition => TPartition, FieldSchema}
2828
import org.apache.hadoop.hive.ql.metadata._
2929
import org.apache.hadoop.hive.ql.plan.CreateTableDesc
30+
import org.apache.hadoop.hive.ql.session.SessionState
3031
import org.apache.hadoop.hive.serde.serdeConstants
3132
import org.apache.hadoop.hive.serde2.{Deserializer, SerDeException}
3233
import org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe
@@ -402,6 +403,9 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with
402403
val desc: Option[CreateTableDesc] = if (tableExists(Seq(databaseName, tblName))) {
403404
None
404405
} else {
406+
// Set the current SessionState to our own SessionState. So, we will make sure
407+
// this state can be picked up inside analyzeInternal.
408+
SessionState.setCurrentSessionState(hive.sessionState)
405409
val sa = new SemanticAnalyzer(hive.hiveconf) {
406410
override def analyzeInternal(ast: ASTNode) {
407411
// A hack to intercept the SemanticAnalyzer.analyzeInternal,

0 commit comments

Comments
 (0)