LantaoJin commented on a change in pull request #26097: [SPARK-29421][SQL] 
Supporting Create Table Like Using Provider
URL: https://github.com/apache/spark/pull/26097#discussion_r344423981
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
 ##########
 @@ -2817,4 +2817,42 @@ abstract class DDLSuite extends QueryTest with 
SQLTestUtils {
       }
     }
   }
+
+  test("SPARK-29421: Create Table LIKE USING provider") {
+    val catalog = spark.sessionState.catalog
+    withTable("s", "t1", "t2", "t3", "t4", "t5") {
+      sql("CREATE TABLE s(a INT, b INT) USING parquet")
+      val source = catalog.getTableMetadata(TableIdentifier("s"))
+      assert(source.provider == Some("parquet"))
+
+      sql("CREATE TABLE t1 LIKE s USING orc")
+      val table1 = catalog.getTableMetadata(TableIdentifier("t1"))
+      assert(table1.provider == Some("orc"))
+
+      sql("CREATE TABLE t2 LIKE s USING com.databricks.spark.csv")
+      val table2 = catalog.getTableMetadata(TableIdentifier("t2"))
+      assert(table2.provider == Some("com.databricks.spark.csv"))
+
+      val e1 = intercept[ClassNotFoundException] {
+        sql("CREATE TABLE t3 LIKE s USING com.databricks.Spark.csv")
+      }.getMessage
+      assert(e1.contains("Failed to find data source: 
com.databricks.Spark.csv"))
+
+      val e2 = intercept[ClassNotFoundException] {
+        sql("CREATE TABLE t4 LIKE s USING unknown")
+      }.getMessage
+      assert(e2.contains("Failed to find data source"))
+
+      if (spark.sparkContext.conf.get(CATALOG_IMPLEMENTATION) == "hive") {
 
 Review comment:
   Sure. I will move it to `HiveDDLSuite`

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to