cloud-fan commented on code in PR #43949: URL: https://github.com/apache/spark/pull/43949#discussion_r1401567348
########## sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2Suite.scala: ########## @@ -633,6 +633,38 @@ class DataSourceV2Suite extends QueryTest with SharedSparkSession with AdaptiveS } } } + + test("SPARK-46043: Support create table using DSv2 sources") { + Seq(classOf[SimpleDataSourceV2], classOf[JavaSimpleDataSourceV2]).foreach { cls => + withClue(cls.getName) { + 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))) + } + } + } + withTable("test") { + val cls = classOf[SchemaRequiredDataSource] + withClue(cls.getName) { + sql(s"CREATE TABLE test USING ${cls.getName}") + checkAnswer(sql(s"SELECT * FROM test"), Nil) + } + } + withTable("test") { + val cls = classOf[SupportsExternalMetadataWritableDataSource] + withClue(cls.getName) { + withTempDir { dir => + sql(s"CREATE TABLE test USING ${cls.getName} OPTIONS (path '${dir.getCanonicalPath}')") + checkAnswer(sql(s"SELECT * FROM test"), Nil) Review Comment: we should at least test the table schema if there is no data. -- 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