Skip to content

Conversation

@mariosmeim-db
Copy link
Contributor

@mariosmeim-db mariosmeim-db commented May 20, 2021

What changes were proposed in this pull request?

Override getJDBCType method in MySQLDialect so that FloatType is mapped to FLOAT instead of REAL

Why are the changes needed?

MySQL treats REAL as a synonym to DOUBLE by default (see https://dev.mysql.com/doc/refman/8.0/en/numeric-types.html). Therefore, when creating a table with a column of REAL type, it will be created as DOUBLE. However, currently, MySQLDialect does not provide an implementation for getJDBCType, and will thus ultimately fall back to JdbcUtils.getCommonJDBCType, which maps FloatType to REAL. This change is needed so that we can properly map the FloatType to FLOAT for MySQL.

Does this PR introduce any user-facing change?

Prior to this PR, when writing a dataframe with a FloatType column to a MySQL table, it will create a DOUBLE column. After the PR, it will create a FLOAT column.

How was this patch tested?

Added a test case in JDBCSuite that verifies the mapping.

@github-actions github-actions bot added the SQL label May 20, 2021
@HyukjinKwon
Copy link
Member

ok to test

@HyukjinKwon
Copy link
Member

cc @maropu FYI

@maropu
Copy link
Member

maropu commented May 20, 2021

Thank you for the your contribution, @mariosmeim-db . Could you add tests in MySQLIntegrationSuite, too? Our test framework does not run the integration test now, so please run it on your env.

Thank you for pining me, @HyukjinKwon. btw, is it better to run these integration tests in GA, too?

@SparkQA
Copy link

SparkQA commented May 20, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43270/

@SparkQA
Copy link

SparkQA commented May 20, 2021

Test build #138748 has finished for PR 32605 at commit 30e6717.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 20, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43270/

@srowen
Copy link
Member

srowen commented May 20, 2021

Jenkins test this please

@SparkQA
Copy link

SparkQA commented May 20, 2021

Test build #138773 has started for PR 32605 at commit 30e6717.

@SparkQA
Copy link

SparkQA commented May 21, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43296/

@SparkQA
Copy link

SparkQA commented May 21, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43296/

@maropu
Copy link
Member

maropu commented May 22, 2021

Thank you for pining me, @HyukjinKwon. btw, is it better to run these integration tests in GA, too?

See #32620 for the related work.

@SparkQA
Copy link

SparkQA commented May 25, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43454/

@SparkQA
Copy link

SparkQA commented May 25, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43454/

@SparkQA
Copy link

SparkQA commented May 25, 2021

Test build #138933 has finished for PR 32605 at commit 60afab1.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mariosmeim-db mariosmeim-db requested a review from HyukjinKwon May 27, 2021 15:46
@mariosmeim-db mariosmeim-db changed the title [WIP][SPARK-35446] Override getJDBCType in MySQLDialect to map FloatType to FLOAT [SPARK-35446] Override getJDBCType in MySQLDialect to map FloatType to FLOAT May 27, 2021
@mariosmeim-db mariosmeim-db requested a review from maropu May 27, 2021 15:47
Copy link
Member

@HyukjinKwon HyukjinKwon left a 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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions bot added the DOCS label Jun 4, 2021
@SparkQA
Copy link

SparkQA commented Jun 4, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43850/

@SparkQA
Copy link

SparkQA commented Jun 4, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43850/

@SparkQA
Copy link

SparkQA commented Jun 4, 2021

Test build #139328 has finished for PR 32605 at commit 77cf81c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

Merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants