You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "sunxiaoguang (via GitHub)" <gi...@apache.org> on 2025/01/13 06:40:57 UTC
Re: [PR] [SPARK-50793][SQL] Fix MySQL cast function for DOUBLE, LONGTEXT, SMALLINT, INTEGER, BIGINT and BLOB types [spark]
sunxiaoguang commented on code in PR #49453:
URL: https://github.com/apache/spark/pull/49453#discussion_r1912728676
##########
connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/MySQLIntegrationSuite.scala:
##########
@@ -241,6 +241,37 @@ class MySQLIntegrationSuite extends DockerJDBCIntegrationV2Suite with V2JDBCTest
assert(rows10(0).getString(0) === "amy")
assert(rows10(1).getString(0) === "alex")
}
+
+ test("SPARK-50793: MySQL JDBC Connector failed to cast some types") {
+ val tableName = catalogName + ".test_cast_function"
+ withTable(tableName) {
+ // CREATE table to use types defined in Spark SQL
+ sql(s"""CREATE TABLE $tableName (
+ string_col STRING,
+ short_col SHORT,
+ integer_col INTEGER,
+ long_col LONG,
+ binary_col BINARY,
+ double_col DOUBLE
+ )""")
+ sql(s"INSERT INTO $tableName VALUES('0', 0, 0, 0, x'30', 0.0)")
+
+ def testCast(castType: String, sourceCol: String, targetCol: String): Unit = {
+ val sql = s"SELECT * FROM $tableName WHERE CAST($sourceCol AS $castType) = $targetCol"
+ assert(spark.sql(sql).collect().length === 1)
Review Comment:
Sure, let me add that.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org