cloud-fan commented on code in PR #51616:
URL: https://github.com/apache/spark/pull/51616#discussion_r2224416196


##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -157,102 +157,101 @@ class JDBCV2Suite extends QueryTest with 
SharedSparkSession with ExplainSuiteHel
     super.beforeAll()
     Utils.classForName("org.h2.Driver")
     withConnection { conn =>
-      conn.prepareStatement("CREATE SCHEMA \"test\"").executeUpdate()
-      conn.prepareStatement(
+
+      val batchStmt = conn.createStatement()
+      batchStmt.addBatch("CREATE SCHEMA \"test\"")
+
+      batchStmt.addBatch(
         "CREATE TABLE \"test\".\"empty_table\" (name TEXT(32) NOT NULL, id 
INTEGER NOT NULL)")
-        .executeUpdate()
-      conn.prepareStatement(
+
+      batchStmt.addBatch(
         "CREATE TABLE \"test\".\"people\" (name TEXT(32) NOT NULL, id INTEGER 
NOT NULL)")
-        .executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"people\" VALUES ('fred', 
1)").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"people\" VALUES ('mary', 
2)").executeUpdate()
-      conn.prepareStatement(
+
+      batchStmt.addBatch(
         "CREATE TABLE \"test\".\"employee\" (dept INTEGER, name TEXT(32), 
salary NUMERIC(20, 2)," +
-          " bonus DOUBLE, is_manager BOOLEAN)").executeUpdate()
-      conn.prepareStatement(
-        "INSERT INTO \"test\".\"employee\" VALUES (1, 'amy', 10000, 1000, 
true)").executeUpdate()
-      conn.prepareStatement(
-        "INSERT INTO \"test\".\"employee\" VALUES (2, 'alex', 12000, 1200, 
false)").executeUpdate()
-      conn.prepareStatement(
-        "INSERT INTO \"test\".\"employee\" VALUES (1, 'cathy', 9000, 1200, 
false)").executeUpdate()
-      conn.prepareStatement(
-        "INSERT INTO \"test\".\"employee\" VALUES (2, 'david', 10000, 1300, 
true)").executeUpdate()
-      conn.prepareStatement(
-        "INSERT INTO \"test\".\"employee\" VALUES (6, 'jen', 12000, 1200, 
true)").executeUpdate()
-      conn.prepareStatement(
+          " bonus DOUBLE, is_manager BOOLEAN)")
+
+      batchStmt.addBatch(
         "CREATE TABLE \"test\".\"dept\" (\"dept id\" INTEGER NOT NULL, 
\"dept.id\" INTEGER)")
-        .executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"dept\" VALUES (1, 
1)").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"dept\" VALUES (2, 
1)").executeUpdate()
 
       // scalastyle:off
-      conn.prepareStatement(
-        "CREATE TABLE \"test\".\"person\" (\"名\" INTEGER NOT 
NULL)").executeUpdate()
+      batchStmt.addBatch("CREATE TABLE \"test\".\"person\" (\"名\" INTEGER NOT 
NULL)")
       // scalastyle:on
-      conn.prepareStatement("INSERT INTO \"test\".\"person\" VALUES 
(1)").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"person\" VALUES 
(2)").executeUpdate()
-      conn.prepareStatement(
-        """CREATE TABLE "test"."view1" ("|col1" INTEGER, "|col2" 
INTEGER)""").executeUpdate()
-      conn.prepareStatement(
-        """CREATE TABLE "test"."view2" ("|col1" INTEGER, "|col3" 
INTEGER)""").executeUpdate()
-
-      conn.prepareStatement(
+
+      batchStmt.addBatch(
+        """CREATE TABLE "test"."view1" ("|col1" INTEGER, "|col2" INTEGER)""")
+      batchStmt.addBatch(
+        """CREATE TABLE "test"."view2" ("|col1" INTEGER, "|col3" INTEGER)""")
+
+      batchStmt.addBatch(
         "CREATE TABLE \"test\".\"item\" (id INTEGER, name TEXT(32), price 
NUMERIC(23, 3))")
-        .executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"item\" VALUES " +
-        "(1, 'bottle', 11111111111111111111.123)").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"item\" VALUES " +
-        "(1, 'bottle', 99999999999999999999.123)").executeUpdate()
 
-      conn.prepareStatement(
+      batchStmt.addBatch(
         "CREATE TABLE \"test\".\"datetime\" (name TEXT(32), date1 DATE, time1 
TIMESTAMP)")
-        .executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"datetime\" VALUES " +
-        "('amy', '2022-05-19', '2022-05-19 00:00:00')").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"datetime\" VALUES " +
-        "('alex', '2022-05-18', '2022-05-18 00:00:00')").executeUpdate()
-
-      conn.prepareStatement(
-        "CREATE TABLE \"test\".\"address\" (email TEXT(32) NOT 
NULL)").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"address\" VALUES " +
-        "('abc_...@gmail.com')").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"address\" VALUES " +
-        "('abc%...@gmail.com')").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"address\" VALUES " +
-        "('abc%_...@gmail.com')").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"address\" VALUES " +
-        "('abc_%...@gmail.com')").executeUpdate()
-      conn.prepareStatement("INSERT INTO \"test\".\"address\" VALUES " +
-        "('abc_''%d...@gmail.com')").executeUpdate()
-
-      conn.prepareStatement("CREATE TABLE \"test\".\"binary_tab\" (name 
TEXT(32),b BINARY(20))")
-        .executeUpdate()
+
+      batchStmt.addBatch(
+        "CREATE TABLE \"test\".\"address\" (email TEXT(32) NOT NULL)")
+
+      batchStmt.addBatch("CREATE TABLE \"test\".\"binary_tab\" (name 
TEXT(32),b BINARY(20))")
+
+      batchStmt.addBatch("CREATE TABLE \"test\".\"employee_bonus\" " +
+        "(name TEXT(32), salary NUMERIC(20, 2), bonus DOUBLE, factor DOUBLE)")
+
+      batchStmt.addBatch(
+        "CREATE TABLE \"test\".\"strings_with_nulls\" (str TEXT(32))")
+
+      batchStmt.addBatch("INSERT INTO \"test\".\"people\" VALUES ('fred', 1)")

Review Comment:
   in this suite, CREATE TABLE and INSERT are in one batch. Why can't we do the 
same for `JDBCSuite.scala`?



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

Reply via email to