cloud-fan commented on code in PR #43949: URL: https://github.com/apache/spark/pull/43949#discussion_r1411879434
########## sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2Suite.scala: ########## @@ -633,6 +634,95 @@ class DataSourceV2Suite extends QueryTest with SharedSparkSession with AdaptiveS } } } + + test("SPARK-46043: create table in SQL using a DSv2 source") { + Seq(classOf[SimpleDataSourceV2], classOf[JavaSimpleDataSourceV2]).foreach { cls => + withClue(cls.getName) { + // Create a table with empty schema. + withTable("test") { + sql(s"CREATE TABLE test USING ${cls.getName}") + checkAnswer( + sql(s"SELECT * FROM test WHERE i < 3"), + Seq(Row(0, 0), Row(1, -1), Row(2, -2))) + } + // Create a table with non-empty schema is not allowed. + checkError( + exception = intercept[SparkUnsupportedOperationException] { + sql(s"CREATE TABLE test(a INT, b INT) USING ${cls.getName}") + }, + errorClass = "CANNOT_CREATE_DATA_SOURCE_TABLE.EXTERNAL_METADATA_UNSUPPORTED", + parameters = Map("tableName" -> "default.test", "provider" -> cls.getName) Review Comment: it should be `"`default`.`test`"` -- 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. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org