maropu commented on a change in pull request #29945:
URL: https://github.com/apache/spark/pull/29945#discussion_r499941319



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala
##########
@@ -121,16 +163,38 @@ class JDBCTableCatalogSuite extends QueryTest with 
SharedSparkSession {
       t = spark.table("h2.test.alt_table")
       expectedSchema = expectedSchema.add("C3", DoubleType)
       assert(t.schema === expectedSchema)
+      // Add already existing column
+      intercept[AnalysisException] {
+        sql(s"ALTER TABLE h2.test.alt_table ADD COLUMNS (C3 DOUBLE)")

Review comment:
       ditto

##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala
##########
@@ -87,6 +95,26 @@ class JDBCTableCatalogSuite extends QueryTest with 
SharedSparkSession {
         sql("SHOW TABLES IN h2.test"),
         Seq(Row("test", "dst_table"), Row("test", "people")))
     }
+    // Rename not existing table or namespace
+    Seq("h2.test.not_existing_table", 
"h2.bad_test.not_existing_table").foreach { table =>
+      intercept[org.h2.jdbc.JdbcSQLException] {
+        sql(s"ALTER TABLE $table RENAME TO test.dst_table")
+      }
+    }
+    // Rename to an existing table
+    withTable("h2.test.dst_table") {
+      withConnection { conn =>
+        conn.prepareStatement("""CREATE TABLE "test"."dst_table" (id 
INTEGER)""").executeUpdate()
+      }
+      withTable("h2.test.src_table") {
+        withConnection { conn =>
+          conn.prepareStatement("""CREATE TABLE "test"."src_table" (id 
INTEGER)""").executeUpdate()
+        }
+        intercept[org.h2.jdbc.JdbcSQLException] {
+          sql(s"ALTER TABLE h2.test.src_table RENAME TO h2.test.dst_table")

Review comment:
       nit: remove `s`




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to