Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ case class CreateViewCommand(
originalText))
} else {
TemporaryViewRelation(
prepareTemporaryViewFromDataFrame(name, aliasedPlan),
prepareTemporaryViewFromDataFrame(viewIdent, aliasedPlan),
Some(aliasedPlan))
}
catalog.createGlobalTempView(name.table, tableDefinition, overrideIfExists = replace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.analysis.NoSuchTableException
import org.apache.spark.sql.catalyst.parser.ParseException
import org.apache.spark.sql.catalyst.plans.logical.View
import org.apache.spark.sql.internal.SQLConf._
import org.apache.spark.sql.test.{SharedSparkSession, SQLTestUtils}

Expand Down Expand Up @@ -909,4 +910,21 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
}
}
}

test("SPARK-34152: global temp view's identifier should be correctly stored") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move it to the new GlobalTempViewTestSuite? we should slowly move all the view tests to SQLViewTestSuite framework.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for @cloud-fan 's suggestion.

Seq(true, false).foreach { storeAnalyzed =>
withSQLConf(STORE_ANALYZED_PLAN_FOR_VIEW.key -> storeAnalyzed.toString) {
withGlobalTempView("v") {
sql("CREATE GLOBAL TEMPORARY VIEW v AS SELECT 1")
val globalTempDB = spark.sharedState.globalTempViewManager.database
val globalTempView = spark.sessionState.catalog.getGlobalTempView("v")
globalTempView match {
case Some(v: View) if v.isTempView =>
assert(v.desc.identifier == TableIdentifier("v", Some(globalTempDB)))
case _ => fail(s"Global temp view not found: $globalTempDB.v")
}
}
}
}
}
}