maropu commented on a change in pull request #25243: [SPARK-28498][SQL][TEST]
always create a fresh copy of the SparkSession before each test
URL: https://github.com/apache/spark/pull/25243#discussion_r307259405
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala
##########
@@ -1799,19 +1787,17 @@ class DataFrameSuite extends QueryTest with
SharedSQLContext {
test("SPARK-17409: Do Not Optimize Query in CTAS (Data source tables) More
Than Once") {
withTable("bar") {
- withTempView("foo") {
- withSQLConf(SQLConf.DEFAULT_DATA_SOURCE_NAME.key -> "json") {
- sql("select 0 as id").createOrReplaceTempView("foo")
- val df = sql("select * from foo group by id")
- // If we optimize the query in CTAS more than once, the following
saveAsTable will fail
- // with the error: `GROUP BY position 0 is not in select list (valid
range is [1, 1])`
- df.write.mode("overwrite").saveAsTable("bar")
- checkAnswer(spark.table("bar"), Row(0) :: Nil)
- val tableMetadata =
spark.sessionState.catalog.getTableMetadata(TableIdentifier("bar"))
- assert(tableMetadata.provider == Some("json"),
- "the expected table is a data source table using json")
- }
- }
+ spark.sessionState.conf.setConf(SQLConf.DEFAULT_DATA_SOURCE_NAME, "json")
+ sql("select 0 as id").createOrReplaceTempView("foo")
+ val df = sql("select * from foo group by id")
+ // If we optimize the query in CTAS more than once, the following
saveAsTable will fail
+ // with the error: `GROUP BY position 0 is not in select list (valid
range is [1, 1])`
+ df.write.mode("overwrite").saveAsTable("bar")
+ checkAnswer(spark.table("bar"), Row(0) :: Nil)
+ val tableMetadata =
spark.sessionState.catalog.getTableMetadata(TableIdentifier("bar"))
+ assert(tableMetadata.provider == Some("json"),
+ "the expected table is a data source table using json")
+
Review comment:
nit: remove a blank line.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]