Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class PostgresIntegrationSuite extends DockerJDBCIntegrationSuite {
).executeUpdate()
conn.prepareStatement("INSERT INTO char_types VALUES " +
"('abcd', 'efgh', 'ijkl', 'mnop', 'q')").executeUpdate()

conn.prepareStatement("CREATE TABLE char_array_types (" +
"c0 char(4)[], c1 character(4)[], c2 character varying(4)[], c3 varchar(4)[], c4 bpchar[])"
).executeUpdate()
conn.prepareStatement("INSERT INTO char_array_types VALUES " +
"""('{"a", "bcd"}', '{"ef", "gh"}', '{"i", "j", "kl"}', '{"mnop"}', '{"q", "r"}')"""
).executeUpdate()
}

test("Type mapping for various types") {
Expand Down Expand Up @@ -235,4 +242,16 @@ class PostgresIntegrationSuite extends DockerJDBCIntegrationSuite {
assert(row(0).getString(3) === "mnop")
assert(row(0).getString(4) === "q")
}

test("SPARK-32576: character array type tests") {
val df = sqlContext.read.jdbc(jdbcUrl, "char_array_types", new Properties)
val row = df.collect()
assert(row.length == 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: ===

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I missed that. But, its trivial, so I'll fix it next time I update this file. Anyway, thanks for the check, @yaooqinn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's alright. We don't currently have a style rule for that. == is already being used here and there too though I prefer === as well because it can compare, for example, arrays properly with a good error message.

assert(row(0).length === 5)
assert(row(0).getSeq[String](0) === Seq("a ", "bcd "))
assert(row(0).getSeq[String](1) === Seq("ef ", "gh "))
assert(row(0).getSeq[String](2) === Seq("i", "j", "kl"))
assert(row(0).getSeq[String](3) === Seq("mnop"))
assert(row(0).getSeq[String](4) === Seq("q", "r"))
}
}