rdblue commented on a change in pull request #25104: [SPARK-28341][SQL] refine 
the v2 session catalog config
URL: https://github.com/apache/spark/pull/25104#discussion_r303083908
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2SQLSuite.scala
 ##########
 @@ -176,26 +182,31 @@ class DataSourceV2SQLSuite extends QueryTest with 
SharedSQLContext with BeforeAn
   }
 
   test("CreateTableAsSelect: use v2 plan and session catalog when provider is 
v2") {
-    spark.sql(s"CREATE TABLE table_name USING $orc2 AS SELECT id, data FROM 
source")
-
-    val testCatalog = spark.catalog("session").asTableCatalog
-    val table = testCatalog.loadTable(Identifier.of(Array(), "table_name"))
-
+    // TODO: `V2SessionCatalog#loadTable` should return writable table.
+    val e = intercept[Exception] {
+      spark.sql(s"CREATE TABLE table_name USING $orc2 AS SELECT id, data FROM 
source")
+    }
+    assert(e.getMessage.contains("Table implementation does not support 
writes: table_name"))
+    spark.sql("DROP TABLE IF EXISTS table_name")
+
+    val newSession = spark.newSession()
+    newSession.sessionState.conf.setConf(
+      StaticSQLConf.V2_SESSION_CATALOG_IMPL, 
classOf[MyV2SessionCatalog].getName)
+    newSession.sql(s"CREATE TABLE table_name USING $orc2 AS SELECT 1 as a")
+    val sessionCatalog = getV2SessionCatalog(newSession)
+    val table = sessionCatalog.loadTable(Identifier.of(Array(), "table_name"))
     assert(table.name == "session.table_name")
     assert(table.partitioning.isEmpty)
     assert(table.properties == Map("provider" -> orc2).asJava)
-    assert(table.schema == new StructType()
-        .add("id", LongType, nullable = false)
-        .add("data", StringType))
-
+    assert(table.schema == new StructType().add("a", IntegerType, nullable = 
false))
 
 Review comment:
   This should use the original test case to minimize changes.

----------------------------------------------------------------
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]

Reply via email to