aleksandar-trajkovic-db commented on code in PR #60455:
URL: https://github.com/apache/spark/pull/60455#discussion_r4599056804
##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MySQLDialect.scala:
##########
@@ -130,11 +130,19 @@ private case class MySQLDialect() extends JdbcDialect
with SQLConfHelper with No
// The common JDBC mapping is DOUBLE PRECISION, which is not a
portable CAST target for
// MySQL-compatible databases. In particular, MariaDB rejects it
with a syntax error.
throw new UnsupportedOperationException("Cannot cast to double type")
- // MySQL does not support casting to SHORT, INT or BIGINT, it uses
SIGNED instead.
- case _: IntegralType if exprDataType.isInstanceOf[FractionalType] &&
- !conf.legacyJdbcRoundIntegralCastPushdown =>
- s"CAST(${truncateFractionalValue(expr)} AS SIGNED)"
- case _: IntegralType => s"CAST($expr AS SIGNED)"
+ // MySQL's only integral CAST target is 64-bit SIGNED, which matches
Spark only for BIGINT
+ // casts from FLOAT, DOUBLE, or a DECIMAL that fits 64 bits. Spark
evaluates other casts.
+ case LongType if !conf.legacyJdbcRoundIntegralCastPushdown &&
(exprDataType match {
+ case FloatType | DoubleType => true
Review Comment:
Good catch, this doesn't seem to be an issue on MySQL, it seems to raise an
error on overflows by default, but it does seem to be an issue on MariaDB which
silently clips the value
--
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]