You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2024/07/31 15:59:23 UTC

(spark) branch branch-3.5 updated: [SPARK-44638][SQL][TESTS][3.5] Add test for Char/Varchar in JDBC customSchema option

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.5 by this push:
     new a0f88f5f4522 [SPARK-44638][SQL][TESTS][3.5] Add test for Char/Varchar in JDBC customSchema option
a0f88f5f4522 is described below

commit a0f88f5f452285e640b7e6c414a16c07287816ba
Author: Kent Yao <ya...@apache.org>
AuthorDate: Wed Jul 31 08:59:13 2024 -0700

    [SPARK-44638][SQL][TESTS][3.5] Add test for Char/Varchar in JDBC customSchema option
    
    ### What changes were proposed in this pull request?
    
    Char/Varchar in JDBC `customSchema` option once broke in Spark 3.1 ~ 3.4, but seem to be restored in master by some recent works in the JDBC area, this PR add a test to cover.
    
    ### Why are the changes needed?
    
    test cov
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    
    ### How was this patch tested?
    
    test added
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    no
    
    Closes #47550 from yaooqinn/SPARK-44638-F.
    
    Authored-by: Kent Yao <ya...@apache.org>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 .../scala/org/apache/spark/sql/jdbc/MySQLIntegrationSuite.scala  | 9 +++++++++
 1 file changed, 9 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 bc7302163d9a..cefbe41b64bd 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
@@ -220,6 +220,15 @@ class MySQLIntegrationSuite extends DockerJDBCIntegrationSuite {
     val nulls = spark.read.jdbc(jdbcUrl, "numbers", new Properties).tail(1).head
     assert(nulls === Row(null, null, null, null, null, null, null, null, null, null, null))
   }
+
+  test("SPARK-44638: Char/Varchar in Custom Schema") {
+    val df = spark.read.option("url", jdbcUrl)
+      .option("query", "SELECT c, d from strings")
+      .option("customSchema", "c CHAR(10), d VARCHAR(10)")
+      .format("jdbc")
+      .load()
+    assert(df.head === Row("brown     ", "fox"))
+  }
 }
 
 /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org