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 2020/08/10 01:40:57 UTC

[spark] branch branch-3.0 updated: [SPARK-32393][SQL][TEST] Add tests for all the character types in PostgresIntegrationSuite

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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 0f4989c  [SPARK-32393][SQL][TEST] Add tests for all the character types in PostgresIntegrationSuite
0f4989c is described below

commit 0f4989cb6f52f2266768a075b98b4dea7f25e89c
Author: Takeshi Yamamuro <ya...@apache.org>
AuthorDate: Sun Aug 9 18:36:35 2020 -0700

    [SPARK-32393][SQL][TEST] Add tests for all the character types in PostgresIntegrationSuite
    
    ### What changes were proposed in this pull request?
    
    This PR intends to add tests to check if all the character types in PostgreSQL supported.
    
    The document for character types in PostgreSQL: https://www.postgresql.org/docs/current/datatype-character.html
    
    Closes #29192.
    
    ### Why are the changes needed?
    
    For better test coverage.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Add tests.
    
    Closes #29394 from maropu/pr29192.
    
    Lead-authored-by: Takeshi Yamamuro <ya...@apache.org>
    Co-authored-by: kujon <ja...@vortexa.com>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
    (cherry picked from commit b2c45f7dcfe62e76f74726c97385440fead70646)
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../spark/sql/jdbc/PostgresIntegrationSuite.scala   | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala b/external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala
index 599f00d..1914491 100644
--- a/external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala
+++ b/external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala
@@ -77,8 +77,13 @@ class PostgresIntegrationSuite extends DockerJDBCIntegrationSuite {
       "'172.16.0.42']::inet[], ARRAY['192.168.0.0/24', '10.1.0.0/16']::cidr[], " +
       """ARRAY['{"a": "foo", "b": "bar"}', '{"a": 1, "b": 2}']::json[], """ +
       """ARRAY['{"a": 1, "b": 2, "c": 3}']::jsonb[])"""
-    )
-      .executeUpdate()
+    ).executeUpdate()
+
+    conn.prepareStatement("CREATE TABLE char_types (" +
+      "c0 char(4), c1 character(4), c2 character varying(4), c3 varchar(4), c4 bpchar)"
+    ).executeUpdate()
+    conn.prepareStatement("INSERT INTO char_types VALUES " +
+      "('abcd', 'efgh', 'ijkl', 'mnop', 'q')").executeUpdate()
   }
 
   test("Type mapping for various types") {
@@ -219,4 +224,16 @@ class PostgresIntegrationSuite extends DockerJDBCIntegrationSuite {
     assert(rows(0).getShort(0) === 1)
     assert(rows(0).getShort(1) === 2)
   }
+
+  test("character type tests") {
+    val df = sqlContext.read.jdbc(jdbcUrl, "char_types", new Properties)
+    val row = df.collect()
+    assert(row.length == 1)
+    assert(row(0).length === 5)
+    assert(row(0).getString(0) === "abcd")
+    assert(row(0).getString(1) === "efgh")
+    assert(row(0).getString(2) === "ijkl")
+    assert(row(0).getString(3) === "mnop")
+    assert(row(0).getString(4) === "q")
+  }
 }


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