[
https://issues.apache.org/jira/browse/SPARK-58372?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Uroš Bojanić resolved SPARK-58372.
----------------------------------
Fix Version/s: 4.5.0
Resolution: Fixed
Issue resolved by pull request 60455
[https://github.com/apache/spark/pull/60455]
> Truncate fractional to integral casts pushed down to JDBC sources
> -----------------------------------------------------------------
>
> Key: SPARK-58372
> URL: https://issues.apache.org/jira/browse/SPARK-58372
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 4.5.0
> Reporter: Marko Sisovic
> Assignee: Aleksandar Trajković
> Priority: Major
> Labels: pull-request-available
> Fix For: 4.5.0
>
>
> Spark truncates toward zero when casting a fractional value to an integral
> type, but MySQL, Oracle, Postgres and Snowflake round half away from zero.
> When such a cast is pushed down to the JDBC source, the query silently
> returns different results than Spark would produce locally - there is no
> error, just wrong values.
> Given a table with the values 1.5, 2.5 and -1.5:
> {code:java}
> SELECT CAST(c AS INT) FROM t {code}
> Spark returns 1, 2, -1, while these databases return 2, 3, -2.
> The same divergence affects filters, where the rows are then eliminated on
> the database side, so WHERE CAST(c AS INT) = 2 matches a different row than
> Spark would.
> Affected dialects are the ones whose database rounds: MySQL, Oracle, Postgres
> and Snowflake. Dialects whose cast already truncates like Spark (MS SQL
> Server, DB2, Derby, H2, Teradata) are not affected.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]