This is an automated email from the ASF dual-hosted git repository. dongjoon 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 9a20794b252d [SPARK-47701][SQL][TESTS] Postgres: Add test for Composite and Range types 9a20794b252d is described below commit 9a20794b252d207b6864f656e7fab85007911537 Author: Kent Yao <y...@apache.org> AuthorDate: Tue Apr 2 22:43:05 2024 -0700 [SPARK-47701][SQL][TESTS] Postgres: Add test for Composite and Range types ### What changes were proposed in this pull request? Add tests for Composite and Range types of postgres. ### Why are the changes needed? test improvments ### Does this PR introduce _any_ user-facing change? no, test-only ### How was this patch tested? new tests ### Was this patch authored or co-authored using generative AI tooling? no Closes #45827 from yaooqinn/SPARK-47701. Authored-by: Kent Yao <y...@apache.org> Signed-off-by: Dongjoon Hyun <dh...@apple.com> --- .../spark/sql/jdbc/PostgresIntegrationSuite.scala | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala index 9015434cedd0..f70bd8091204 100644 --- a/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala +++ b/connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala @@ -178,6 +178,15 @@ class PostgresIntegrationSuite extends DockerJDBCIntegrationSuite { conn.prepareStatement("CREATE TABLE test_bit_array (c1 bit(1)[], c2 bit(5)[])").executeUpdate() conn.prepareStatement("INSERT INTO test_bit_array VALUES (ARRAY[B'1', B'0'], " + "ARRAY[B'00001', B'00010'])").executeUpdate() + + conn.prepareStatement( + """ + |CREATE TYPE complex AS ( + | b bool, + | d double precision + |)""".stripMargin).executeUpdate() + conn.prepareStatement("CREATE TABLE complex_table (c1 complex)").executeUpdate() + conn.prepareStatement("INSERT INTO complex_table VALUES (ROW(true, 1.0))").executeUpdate() } test("Type mapping for various types") { @@ -516,4 +525,21 @@ class PostgresIntegrationSuite extends DockerJDBCIntegrationSuite { }, errorClass = null) } + + test("SPARK-47701: Reading complex type") { + val df = spark.read.jdbc(jdbcUrl, "complex_table", new Properties) + checkAnswer(df, Row("(t,1)")) + val df2 = spark.read.format("jdbc") + .option("url", jdbcUrl) + .option("query", "SELECT (c1).b, (c1).d FROM complex_table").load() + checkAnswer(df2, Row(true, 1.0d)) + } + + test("SPARK-47701: Range Types") { + val df = spark.read.format("jdbc") + .option("url", jdbcUrl) + .option("query", "SELECT '[3,7)'::int4range") + .load() + checkAnswer(df, Row("[3,7)")) + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org