mgaido91 commented on a change in pull request #23458: [SPARK-26540][SQL]
Support PostgreSQL numeric arrays without precision/scale
URL: https://github.com/apache/spark/pull/23458#discussion_r245480257
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala
##########
@@ -60,7 +60,10 @@ private object PostgresDialect extends JdbcDialect {
case "bytea" => Some(BinaryType)
case "timestamp" | "timestamptz" | "time" | "timetz" => Some(TimestampType)
case "date" => Some(DateType)
- case "numeric" | "decimal" => Some(DecimalType.bounded(precision, scale))
+ case "numeric" | "decimal" if precision != 0 || scale != 0 =>
Review comment:
Not a very important point, but I think we best use `precision > 0 || scale
> 0`. I mean, there may happen that `scale` is negative. In that case,
precision must be > 0. In the above code a `numeric(0, -10)` which is an
invalid combination is parsed as `DECIMAL(0, -10)`. Probably, we can rely that
this case never happens, but I think having code robust also for error
conditions is better.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]