-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-35446] Override getJDBCType in MySQLDialect to map FloatType to FLOAT #32605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MySQLDialect.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
Outdated
Show resolved
Hide resolved
|
ok to test |
|
cc @maropu FYI |
|
Thank you for the your contribution, @mariosmeim-db . Could you add tests in Thank you for pining me, @HyukjinKwon. btw, is it better to run these integration tests in GA, too? |
|
Kubernetes integration test starting |
|
Test build #138748 has finished for PR 32605 at commit
|
|
Kubernetes integration test status success |
|
Jenkins test this please |
|
Test build #138773 has started for PR 32605 at commit |
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
See #32620 for the related work. |
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Test build #138933 has finished for PR 32605 at commit
|
HyukjinKwon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine.
| override def getJDBCType(dt: DataType): Option[JdbcType] = dt match { | ||
| // See SPARK-35446: MySQL treats REAL as a synonym to DOUBLE by default | ||
| // We override getJDBCType so that FloatType is mapped to FLOAT instead | ||
| case FloatType => Option(JdbcType("FLOAT", java.sql.Types.FLOAT)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mariosmeim-db sorry one last thing. can we update migration guide too? https://github.com/apache/spark/blob/master/docs/sql-migration-guide.md
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #139328 has finished for PR 32605 at commit
|
|
Merged to master. |
What changes were proposed in this pull request?
Override
getJDBCTypemethod inMySQLDialectso thatFloatTypeis mapped toFLOATinstead ofREALWhy are the changes needed?
MySQL treats
REALas a synonym toDOUBLEby default (see https://dev.mysql.com/doc/refman/8.0/en/numeric-types.html). Therefore, when creating a table with a column ofREALtype, it will be created asDOUBLE. However, currently,MySQLDialectdoes not provide an implementation forgetJDBCType, and will thus ultimately fall back toJdbcUtils.getCommonJDBCType, which mapsFloatTypetoREAL. This change is needed so that we can properly map theFloatTypetoFLOATfor MySQL.Does this PR introduce any user-facing change?
Prior to this PR, when writing a dataframe with a
FloatTypecolumn to a MySQL table, it will create aDOUBLEcolumn. After the PR, it will create aFLOATcolumn.How was this patch tested?
Added a test case in
JDBCSuitethat verifies the mapping.