This is an automated email from the ASF dual-hosted git repository. gurwls223 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 a3c04ec11456 [SPARK-47478][SQL][TESTS] Improve test coverage for mysql bool synonyms a3c04ec11456 is described below commit a3c04ec1145662e4227d57cd953bffce96b8aad7 Author: Kent Yao <y...@apache.org> AuthorDate: Wed Mar 20 19:10:41 2024 +0900 [SPARK-47478][SQL][TESTS] Improve test coverage for mysql bool synonyms ### What changes were proposed in this pull request? We have special conversion rules for mapping MySQL boolean synonyms, this PR added some tests to cover the read and write code path ### Why are the changes needed? test coverage improvements ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? added tests ### Was this patch authored or co-authored using generative AI tooling? no Closes #45604 from yaooqinn/SPARK-47478. Authored-by: Kent Yao <y...@apache.org> Signed-off-by: Hyukjin Kwon <gurwls...@apache.org> --- .../spark/sql/jdbc/MySQLIntegrationSuite.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/MySQLIntegrationSuite.scala b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/MySQLIntegrationSuite.scala index db5c86ad93c3..3d65b4f305b3 100644 --- a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/MySQLIntegrationSuite.scala +++ b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/MySQLIntegrationSuite.scala @@ -24,6 +24,7 @@ import java.util.Properties import org.apache.spark.sql.Row import org.apache.spark.sql.catalyst.util.DateTimeTestUtils._ +import org.apache.spark.sql.types.{BooleanType, MetadataBuilder, StructType} import org.apache.spark.tags.DockerTest /** @@ -46,6 +47,10 @@ class MySQLIntegrationSuite extends DockerJDBCIntegrationSuite { conn.prepareStatement("INSERT INTO tbl VALUES (42,'fred')").executeUpdate() conn.prepareStatement("INSERT INTO tbl VALUES (17,'dave')").executeUpdate() + conn.prepareStatement("CREATE TABLE bools (b1 BOOLEAN, b2 BIT(1), b3 TINYINT(1))") + .executeUpdate() + conn.prepareStatement("INSERT INTO bools VALUES (TRUE, b'1', 1)").executeUpdate() + conn.prepareStatement("CREATE TABLE numbers (onebit BIT(1), tenbits BIT(10), " + "small SMALLINT, med MEDIUMINT, nor INT, big BIGINT, deci DECIMAL(40,20), flt FLOAT, " + "dbl DOUBLE, tiny TINYINT, u_tiny TINYINT UNSIGNED)").executeUpdate() @@ -204,4 +209,19 @@ class MySQLIntegrationSuite extends DockerJDBCIntegrationSuite { """.stripMargin.replaceAll("\n", " ")) assert(sql("select x, y from queryOption").collect().toSet == expectedResult) } + + + test("SPARK-47478: all boolean synonyms read-write roundtrip") { + val df = sqlContext.read.jdbc(jdbcUrl, "bools", new Properties) + checkAnswer(df, Row(true, true, true)) + df.write.mode("append").jdbc(jdbcUrl, "bools", new Properties) + checkAnswer(df, Seq(Row(true, true, true), Row(true, true, true))) + val mb = new MetadataBuilder() + .putBoolean("isTimestampNTZ", false) + .putLong("scale", 0) + assert(df.schema === new StructType() + .add("b1", BooleanType, nullable = true, mb.putBoolean("isSigned", true).build()) + .add("b2", BooleanType, nullable = true, mb.putBoolean("isSigned", false).build()) + .add("b3", BooleanType, nullable = true, mb.putBoolean("isSigned", true).build())) + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org