PetarVasiljevic-DB commented on code in PR #48625:
URL: https://github.com/apache/spark/pull/48625#discussion_r1815192500


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala:
##########
@@ -382,18 +382,21 @@ private case class PostgresDialect()
       case Types.ARRAY =>
         val tableName = rsmd.getTableName(columnIdx)
         val columnName = rsmd.getColumnName(columnIdx)
-        val query =
+        val query = if (conf.postgresProperReadingOfArrayDimensionality) {
+             s"SELECT array_ndims($columnName)) FROM $tableName LIMIT 1"
+        } else {
           s"""
              |SELECT pg_attribute.attndims
              |FROM pg_attribute

Review Comment:
   yes. The info about dimensionality is lost when table is creating with CTAS 
command. Some threads that discuss this: 
https://www.postgresql.org/message-id/20150707072942.1186.98151%40wrigleys.postgresql.org,
 https://postgrespro.com/list/thread-id/2304332



##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala:
##########
@@ -382,18 +382,21 @@ private case class PostgresDialect()
       case Types.ARRAY =>
         val tableName = rsmd.getTableName(columnIdx)
         val columnName = rsmd.getColumnName(columnIdx)
-        val query =
+        val query = if (conf.postgresProperReadingOfArrayDimensionality) {
+             s"SELECT array_ndims($columnName)) FROM $tableName LIMIT 1"
+        } else {
           s"""
              |SELECT pg_attribute.attndims
              |FROM pg_attribute

Review Comment:
   yes. The info about dimensionality is lost when table is created with CTAS 
command. Some threads that discuss this: 
https://www.postgresql.org/message-id/20150707072942.1186.98151%40wrigleys.postgresql.org,
 https://postgrespro.com/list/thread-id/2304332



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to