This is an automated email from the ASF dual-hosted git repository. wenchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 5a9929c32ef8 [SPARK-52918][SQL][TESTS] Batch JDBC database statements in JDBC suites 5a9929c32ef8 is described below commit 5a9929c32ef8aafd275a3cf4797bb0ba9a6e61e2 Author: alekjarmov <alek.jar...@databricks.com> AuthorDate: Thu Jul 24 21:12:40 2025 +0800 [SPARK-52918][SQL][TESTS] Batch JDBC database statements in JDBC suites ### What changes were proposed in this pull request? To modify the before all to reduce the amount of roundtrips with the database. Per my benchmarks this led to decreased time in `beforeAll` from ~850ms to ~690ms in `JDBCV2Suite` and 3s to 1.8s in `JDBCSuite`. It also clears tech debt where people in the future won't unknowingly add more roundtrips than needed. ### Why are the changes needed? Improve test performance, it is not drastic improvement when running whole suite but is great when running just a single test. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Test-only change. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claiude Sonnet Closes #51616 from alekjarmov/improve-jdbc-load-tests. Lead-authored-by: alekjarmov <alek.jar...@databricks.com> Co-authored-by: Alek Jarmov <a...@bendingspoons.com> Signed-off-by: Wenchen Fan <wenc...@databricks.com> --- .../org/apache/spark/sql/jdbc/JDBCSuite.scala | 203 +++++++++------------ .../org/apache/spark/sql/jdbc/JDBCV2Suite.scala | 153 ++++++++-------- 2 files changed, 162 insertions(+), 194 deletions(-) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala index 09c2e82c45f1..bed8a1a7b363 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala @@ -102,15 +102,97 @@ class JDBCSuite extends QueryTest with SharedSparkSession { properties.setProperty("password", "testPass") conn = DriverManager.getConnection(url, properties) - conn.prepareStatement("create schema test").executeUpdate() - conn.prepareStatement( - "create table test.people (name TEXT(32) NOT NULL, theid 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( - "insert into test.people values ('joe ''foo'' \"bar\"', 3)").executeUpdate() - conn.commit() + val batchStmt = conn.createStatement() + batchStmt.addBatch("create schema test") + + batchStmt.addBatch("create table test.people (name TEXT(32) NOT NULL, " + + "theid INTEGER NOT NULL)") + batchStmt.addBatch("insert into test.people values ('fred', 1)") + batchStmt.addBatch("insert into test.people values ('mary', 2)") + batchStmt.addBatch("insert into test.people values ('joe ''foo'' \"bar\"', 3)") + + batchStmt.addBatch("create table test.inttypes (a INT, b BOOLEAN, c TINYINT, " + + "d SMALLINT, e BIGINT)") + batchStmt.addBatch("insert into test.inttypes values (1, false, 3, 4, 1234567890123)") + batchStmt.addBatch("insert into test.inttypes values (null, null, null, null, null)") + + batchStmt.addBatch("create table test.timetypes (a TIME, b DATE, c TIMESTAMP(7))") + batchStmt.addBatch("insert into test.timetypes values " + + "('12:34:56', '1996-01-01', '2002-02-20 11:22:33.543543543')") + batchStmt.addBatch("insert into test.timetypes values " + + "('12:34:56', null, '2002-02-20 11:22:33.543543543')") + + batchStmt.addBatch("CREATE TABLE test.timezone (tz TIMESTAMP WITH TIME ZONE) " + + "AS SELECT '1999-01-08 04:05:06.543543543-08:00'") + + batchStmt.addBatch("CREATE TABLE test.array_table (ar Integer ARRAY) " + + "AS SELECT ARRAY[1, 2, 3]") + + batchStmt.addBatch("create table test.flttypes (a DOUBLE, b REAL, c DECIMAL(38, 18))") + batchStmt.addBatch("insert into test.flttypes values " + + "(1.0000000000000002220446049250313080847263336181640625, " + + "1.00000011920928955078125, 123456789012345.543215432154321)") + + batchStmt.addBatch("create table test.nulltypes (a INT, b BOOLEAN, c TINYINT, " + + "d BINARY(20), e VARCHAR(20), f VARCHAR_IGNORECASE(20), g CHAR(20), h BLOB, i CLOB, " + + "j TIME, k DATE, l TIMESTAMP, m DOUBLE, n REAL, o DECIMAL(38, 18))") + batchStmt.addBatch("insert into test.nulltypes values " + + "(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)") + + batchStmt.addBatch("create table test.emp(name TEXT(32) NOT NULL, theid INTEGER, " + + "\"Dept\" INTEGER)") + batchStmt.addBatch("insert into test.emp values ('fred', 1, 10)") + batchStmt.addBatch("insert into test.emp values ('mary', 2, null)") + batchStmt.addBatch("insert into test.emp values ('joe ''foo'' \"bar\"', 3, 30)") + batchStmt.addBatch("insert into test.emp values ('kathy', null, null)") + + batchStmt.addBatch("create table test.seq(id INTEGER)") + (0 to 6).foreach { value => + batchStmt.addBatch(s"insert into test.seq values ($value)") + } + batchStmt.addBatch("insert into test.seq values (null)") + + batchStmt.addBatch("create table test.\"mixedCaseCols\" (\"Name\" TEXT(32), " + + "\"Id\" INTEGER NOT NULL)") + batchStmt.addBatch("""insert into test."mixedCaseCols" values ('fred', 1)""") + batchStmt.addBatch("""insert into test."mixedCaseCols" values ('mary', 2)""") + batchStmt.addBatch("""insert into test."mixedCaseCols" values (null, 3)""") + + batchStmt.addBatch("CREATE TABLE test.partition (THEID INTEGER, `THE ID` INTEGER) " + + "AS SELECT 1, 1") + + batchStmt.addBatch("CREATE TABLE test.datetime (d DATE, t TIMESTAMP)") + batchStmt.addBatch("INSERT INTO test.datetime VALUES " + + "('2018-07-06', '2018-07-06 05:50:00.0')") + batchStmt.addBatch("INSERT INTO test.datetime VALUES " + + "('2018-07-06', '2018-07-06 08:10:08.0')") + batchStmt.addBatch("INSERT INTO test.datetime VALUES " + + "('2018-07-08', '2018-07-08 13:32:01.0')") + batchStmt.addBatch("INSERT INTO test.datetime VALUES " + + "('2018-07-12', '2018-07-12 09:51:15.0')") + + batchStmt.addBatch("CREATE TABLE test.composite_name (`last name` TEXT(32) NOT NULL, " + + "id INTEGER NOT NULL)") + batchStmt.addBatch("INSERT INTO test.composite_name VALUES ('smith', 1)") + batchStmt.addBatch("INSERT INTO test.composite_name VALUES ('jones', 2)") + + batchStmt.executeBatch() + + conn + .prepareStatement("create table test.strtypes" + + "(a BINARY(20), b VARCHAR(20), c VARCHAR_IGNORECASE(20), d CHAR(20), e BLOB, f CLOB)") + .executeUpdate() + val strtypesStmt = conn.prepareStatement("insert into test.strtypes values (?, ?, ?, ?, ?, ?)") + strtypesStmt.setBytes(1, testBytes) + strtypesStmt.setString(2, "Sensitive") + strtypesStmt.setString(3, "Insensitive") + strtypesStmt.setString(4, "Twenty-byte CHAR") + strtypesStmt.setBytes(5, testBytes) + strtypesStmt.setString(6, "I am a clob!") + strtypesStmt.executeUpdate() + + // Spark SQL views creation sql( s""" |CREATE OR REPLACE TEMPORARY VIEW foobar @@ -143,13 +225,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { | upperBound '9223372036854775807', numPartitions '3') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement("create table test.inttypes (a INT, b BOOLEAN, c TINYINT, " - + "d SMALLINT, e BIGINT)").executeUpdate() - conn.prepareStatement("insert into test.inttypes values (1, false, 3, 4, 1234567890123)" - ).executeUpdate() - conn.prepareStatement("insert into test.inttypes values (null, null, null, null, null)" - ).executeUpdate() - conn.commit() sql( s""" |CREATE OR REPLACE TEMPORARY VIEW inttypes @@ -157,16 +232,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { |OPTIONS (url '$url', dbtable 'TEST.INTTYPES', user 'testUser', password 'testPass') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement("create table test.strtypes (a BINARY(20), b VARCHAR(20), " - + "c VARCHAR_IGNORECASE(20), d CHAR(20), e BLOB, f CLOB)").executeUpdate() - val stmt = conn.prepareStatement("insert into test.strtypes values (?, ?, ?, ?, ?, ?)") - stmt.setBytes(1, testBytes) - stmt.setString(2, "Sensitive") - stmt.setString(3, "Insensitive") - stmt.setString(4, "Twenty-byte CHAR") - stmt.setBytes(5, testBytes) - stmt.setString(6, "I am a clob!") - stmt.executeUpdate() sql( s""" |CREATE OR REPLACE TEMPORARY VIEW strtypes @@ -174,13 +239,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { |OPTIONS (url '$url', dbtable 'TEST.STRTYPES', user 'testUser', password 'testPass') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement("create table test.timetypes (a TIME, b DATE, c TIMESTAMP(7))" - ).executeUpdate() - conn.prepareStatement("insert into test.timetypes values ('12:34:56', " - + "'1996-01-01', '2002-02-20 11:22:33.543543543')").executeUpdate() - conn.prepareStatement("insert into test.timetypes values ('12:34:56', " - + "null, '2002-02-20 11:22:33.543543543')").executeUpdate() - conn.commit() sql( s""" |CREATE OR REPLACE TEMPORARY VIEW timetypes @@ -188,23 +246,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { |OPTIONS (url '$url', dbtable 'TEST.TIMETYPES', user 'testUser', password 'testPass') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement("CREATE TABLE test.timezone (tz TIMESTAMP WITH TIME ZONE) " + - "AS SELECT '1999-01-08 04:05:06.543543543-08:00'") - .executeUpdate() - conn.commit() - - conn.prepareStatement("CREATE TABLE test.array_table (ar Integer ARRAY) " + - "AS SELECT ARRAY[1, 2, 3]") - .executeUpdate() - conn.commit() - - conn.prepareStatement("create table test.flttypes (a DOUBLE, b REAL, c DECIMAL(38, 18))" - ).executeUpdate() - conn.prepareStatement("insert into test.flttypes values (" - + "1.0000000000000002220446049250313080847263336181640625, " - + "1.00000011920928955078125, " - + "123456789012345.543215432154321)").executeUpdate() - conn.commit() sql( s""" |CREATE OR REPLACE TEMPORARY VIEW flttypes @@ -212,16 +253,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { |OPTIONS (url '$url', dbtable 'TEST.FLTTYPES', user 'testUser', password 'testPass') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement( - s""" - |create table test.nulltypes (a INT, b BOOLEAN, c TINYINT, d BINARY(20), e VARCHAR(20), - |f VARCHAR_IGNORECASE(20), g CHAR(20), h BLOB, i CLOB, j TIME, k DATE, l TIMESTAMP, - |m DOUBLE, n REAL, o DECIMAL(38, 18)) - """.stripMargin.replaceAll("\n", " ")).executeUpdate() - conn.prepareStatement("insert into test.nulltypes values (" - + "null, null, null, null, null, null, null, null, null, " - + "null, null, null, null, null, null)").executeUpdate() - conn.commit() sql( s""" |CREATE OR REPLACE TEMPORARY VIEW nulltypes @@ -229,29 +260,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { |OPTIONS (url '$url', dbtable 'TEST.NULLTYPES', user 'testUser', password 'testPass') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement( - "create table test.emp(name TEXT(32) NOT NULL," + - " theid INTEGER, \"Dept\" INTEGER)").executeUpdate() - conn.prepareStatement( - "insert into test.emp values ('fred', 1, 10)").executeUpdate() - conn.prepareStatement( - "insert into test.emp values ('mary', 2, null)").executeUpdate() - conn.prepareStatement( - "insert into test.emp values ('joe ''foo'' \"bar\"', 3, 30)").executeUpdate() - conn.prepareStatement( - "insert into test.emp values ('kathy', null, null)").executeUpdate() - conn.commit() - - conn.prepareStatement( - "create table test.seq(id INTEGER)").executeUpdate() - (0 to 6).foreach { value => - conn.prepareStatement( - s"insert into test.seq values ($value)").executeUpdate() - } - conn.prepareStatement( - "insert into test.seq values (null)").executeUpdate() - conn.commit() - sql( s""" |CREATE OR REPLACE TEMPORARY VIEW nullparts @@ -260,14 +268,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { |partitionColumn '"Dept"', lowerBound '1', upperBound '4', numPartitions '3') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement( - """create table test."mixedCaseCols" ("Name" TEXT(32), "Id" INTEGER NOT NULL)""") - .executeUpdate() - conn.prepareStatement("""insert into test."mixedCaseCols" values ('fred', 1)""").executeUpdate() - conn.prepareStatement("""insert into test."mixedCaseCols" values ('mary', 2)""").executeUpdate() - conn.prepareStatement("""insert into test."mixedCaseCols" values (null, 3)""").executeUpdate() - conn.commit() - sql( s""" |CREATE OR REPLACE TEMPORARY VIEW mixedCaseCols @@ -275,29 +275,6 @@ class JDBCSuite extends QueryTest with SharedSparkSession { |OPTIONS (url '$url', dbtable 'TEST."mixedCaseCols"', user 'testUser', password 'testPass') """.stripMargin.replaceAll("\n", " ")) - conn.prepareStatement("CREATE TABLE test.partition (THEID INTEGER, `THE ID` INTEGER) " + - "AS SELECT 1, 1") - .executeUpdate() - conn.commit() - - conn.prepareStatement("CREATE TABLE test.datetime (d DATE, t TIMESTAMP)").executeUpdate() - conn.prepareStatement( - "INSERT INTO test.datetime VALUES ('2018-07-06', '2018-07-06 05:50:00.0')").executeUpdate() - conn.prepareStatement( - "INSERT INTO test.datetime VALUES ('2018-07-06', '2018-07-06 08:10:08.0')").executeUpdate() - conn.prepareStatement( - "INSERT INTO test.datetime VALUES ('2018-07-08', '2018-07-08 13:32:01.0')").executeUpdate() - conn.prepareStatement( - "INSERT INTO test.datetime VALUES ('2018-07-12', '2018-07-12 09:51:15.0')").executeUpdate() - conn.commit() - - conn.prepareStatement( - "CREATE TABLE test.composite_name (`last name` TEXT(32) NOT NULL, id INTEGER NOT NULL)") - .executeUpdate() - conn.prepareStatement("INSERT INTO test.composite_name VALUES ('smith', 1)").executeUpdate() - conn.prepareStatement("INSERT INTO test.composite_name VALUES ('jones', 2)").executeUpdate() - conn.commit() - sql( s""" |CREATE OR REPLACE TEMPORARY VIEW composite_name diff --git a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala index 23761f684b45..d19585a3b8f2 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala @@ -157,102 +157,93 @@ 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("INSERT INTO \"test\".\"people\" VALUES ('fred', 1)") + batchStmt.addBatch("INSERT INTO \"test\".\"people\" VALUES ('mary', 2)") + + 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("INSERT INTO \"test\".\"employee\" VALUES (1, 'amy', 10000, 1000, true)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee\" VALUES (2, 'alex', 12000, 1200, false)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee\" VALUES (1, 'cathy', 9000, 1200, false)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee\" VALUES (2, 'david', 10000, 1300, true)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee\" VALUES (6, 'jen', 12000, 1200, true)") + + 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() + batchStmt.addBatch("INSERT INTO \"test\".\"dept\" VALUES (1, 1)") + batchStmt.addBatch("INSERT INTO \"test\".\"dept\" VALUES (2, 1)") // 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("INSERT INTO \"test\".\"person\" VALUES (1)") + batchStmt.addBatch("INSERT INTO \"test\".\"person\" VALUES (2)") + + 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() + batchStmt.addBatch("INSERT INTO \"test\".\"item\"" + + "VALUES (1, 'bottle', 11111111111111111111.123)") + batchStmt.addBatch("INSERT INTO \"test\".\"item\"" + + "VALUES (1, 'bottle', 99999999999999999999.123)") - 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))") + batchStmt.addBatch("INSERT INTO \"test\".\"datetime\"" + + "VALUES ('amy', '2022-05-19', '2022-05-19 00:00:00')") + batchStmt.addBatch("INSERT INTO \"test\".\"datetime\"" + + "VALUES ('alex', '2022-05-18', '2022-05-18 00:00:00')") + + batchStmt.addBatch( + "CREATE TABLE \"test\".\"address\" (email TEXT(32) NOT NULL)") + batchStmt.addBatch("INSERT INTO \"test\".\"address\" VALUES ('abc_...@gmail.com')") + batchStmt.addBatch("INSERT INTO \"test\".\"address\" VALUES ('abc%...@gmail.com')") + batchStmt.addBatch("INSERT INTO \"test\".\"address\" VALUES ('abc%_...@gmail.com')") + batchStmt.addBatch("INSERT INTO \"test\".\"address\" VALUES ('abc_%...@gmail.com')") + batchStmt.addBatch("INSERT INTO \"test\".\"address\" VALUES ('abc_''%d...@gmail.com')") + + batchStmt.addBatch("CREATE TABLE \"test\".\"employee_bonus\" " + + "(name TEXT(32), salary NUMERIC(20, 2), bonus DOUBLE, factor DOUBLE)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee_bonus\"" + + "VALUES ('amy', 10000, 1000, 0.1)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee_bonus\"" + + "VALUES ('alex', 12000, 1200, 0.1)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee_bonus\"" + + "VALUES ('cathy', 8000, 1200, 0.15)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee_bonus\"" + + "VALUES ('david', 10000, 1300, 0.13)") + batchStmt.addBatch("INSERT INTO \"test\".\"employee_bonus\"" + + "VALUES ('jen', 12000, 2400, 0.2)") + + batchStmt.addBatch( + "CREATE TABLE \"test\".\"strings_with_nulls\" (str TEXT(32))") + batchStmt.addBatch("INSERT INTO \"test\".\"strings_with_nulls\" VALUES ('abc')") + batchStmt.addBatch("INSERT INTO \"test\".\"strings_with_nulls\" VALUES ('a a a')") + batchStmt.addBatch("INSERT INTO \"test\".\"strings_with_nulls\" VALUES (null)") + + batchStmt.executeBatch() + + conn + .prepareStatement("CREATE TABLE \"test\".\"binary_tab\" (name TEXT(32),b BINARY(20))") .executeUpdate() val stmt = conn.prepareStatement("INSERT INTO \"test\".\"binary_tab\" VALUES (?, ?)") stmt.setString(1, "jen") stmt.setBytes(2, testBytes) stmt.executeUpdate() - - conn.prepareStatement("CREATE TABLE \"test\".\"employee_bonus\" " + - "(name TEXT(32), salary NUMERIC(20, 2), bonus DOUBLE, factor DOUBLE)").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"employee_bonus\" " + - "VALUES ('amy', 10000, 1000, 0.1)").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"employee_bonus\" " + - "VALUES ('alex', 12000, 1200, 0.1)").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"employee_bonus\" " + - "VALUES ('cathy', 8000, 1200, 0.15)").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"employee_bonus\" " + - "VALUES ('david', 10000, 1300, 0.13)").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"employee_bonus\" " + - "VALUES ('jen', 12000, 2400, 0.2)").executeUpdate() - - conn.prepareStatement( - "CREATE TABLE \"test\".\"strings_with_nulls\" (str TEXT(32))").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"strings_with_nulls\" VALUES " + - "('abc')").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"strings_with_nulls\" VALUES " + - "('a a a')").executeUpdate() - conn.prepareStatement("INSERT INTO \"test\".\"strings_with_nulls\" VALUES " + - "(null)").executeUpdate() } h2Dialect.registerFunction("my_avg", IntegralAverage) h2Dialect.registerFunction("my_strlen", StrLen(CharLength)) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org