[ 
https://issues.apache.org/jira/browse/SPARK-32393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jakub Korzeniowski updated SPARK-32393:
---------------------------------------
    Description: 
Attempting to read the following table:
{code:java}
CREATE TABLE test_table (
  test_column char(64)[]
)
{code}
results in the following exception:
{code:java}
java.sql.SQLException: Unsupported type ARRAY
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.getCatalystType(JdbcUtils.scala:256)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$getSchema$1(JdbcUtils.scala:321)
        at scala.Option.getOrElse(Option.scala:189)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.getSchema(JdbcUtils.scala:321)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:63)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation$.getSchema(JDBCRelation.scala:226)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:35)
        at 
org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:339)
        at 
org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:279)
        at 
org.apache.spark.sql.DataFrameReader.$anonfun$load$2(DataFrameReader.scala:268)
        at scala.Option.getOrElse(Option.scala:189)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:268)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:203)
{code}
non-array and varchar equivalents are fine.

 

I've tracked it down to an internal function of the postgres dialect, that 
accounts for the special 1-byte char, but doesn't deal with different length 
ones, which postgres represents as bpchar: 
[https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala#L60-L61].

I'll submit a fix shortly

  was:
Attempting to read the following table:
{code:java}
CREATE TABLE test_table (
  parent_ids char(64)[]
)
{code}
results in the following exception:
{code:java}
java.sql.SQLException: Unsupported type ARRAY
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.getCatalystType(JdbcUtils.scala:256)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$getSchema$1(JdbcUtils.scala:321)
        at scala.Option.getOrElse(Option.scala:189)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.getSchema(JdbcUtils.scala:321)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:63)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation$.getSchema(JDBCRelation.scala:226)
        at 
org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:35)
        at 
org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:339)
        at 
org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:279)
        at 
org.apache.spark.sql.DataFrameReader.$anonfun$load$2(DataFrameReader.scala:268)
        at scala.Option.getOrElse(Option.scala:189)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:268)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:203)
{code}
non-array and varchar equivalents are fine.

 

I've tracked it down to an internal function of the postgres dialect, that 
accounts for the special 1-byte char, but doesn't deal with different length 
ones, which postgres represents as bpchar: 
[https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala#L60-L61].

I'll submit a fix shortly


> PostgreSQL: blank-padded, fixed length character arrays are not supported
> -------------------------------------------------------------------------
>
>                 Key: SPARK-32393
>                 URL: https://issues.apache.org/jira/browse/SPARK-32393
>             Project: Spark
>          Issue Type: Bug
>          Components: Input/Output
>    Affects Versions: 3.0.0
>            Reporter: Jakub Korzeniowski
>            Priority: Minor
>
> Attempting to read the following table:
> {code:java}
> CREATE TABLE test_table (
>   test_column char(64)[]
> )
> {code}
> results in the following exception:
> {code:java}
> java.sql.SQLException: Unsupported type ARRAY
>       at 
> org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.getCatalystType(JdbcUtils.scala:256)
>       at 
> org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$getSchema$1(JdbcUtils.scala:321)
>       at scala.Option.getOrElse(Option.scala:189)
>       at 
> org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.getSchema(JdbcUtils.scala:321)
>       at 
> org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:63)
>       at 
> org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation$.getSchema(JDBCRelation.scala:226)
>       at 
> org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:35)
>       at 
> org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:339)
>       at 
> org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:279)
>       at 
> org.apache.spark.sql.DataFrameReader.$anonfun$load$2(DataFrameReader.scala:268)
>       at scala.Option.getOrElse(Option.scala:189)
>       at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:268)
>       at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:203)
> {code}
> non-array and varchar equivalents are fine.
>  
> I've tracked it down to an internal function of the postgres dialect, that 
> accounts for the special 1-byte char, but doesn't deal with different length 
> ones, which postgres represents as bpchar: 
> [https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala#L60-L61].
> I'll submit a fix shortly



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to