Skip to content
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

[SPARK-16387][SQL] JDBC Writer should use dialect to quote field names. #14107

Closed
wants to merge 1 commit into from
Closed

[SPARK-16387][SQL] JDBC Writer should use dialect to quote field names. #14107

wants to merge 1 commit into from

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Jul 8, 2016

What changes were proposed in this pull request?

Currently, JDBC Writer uses dialects to get datatypes, but doesn't to quote field names. This PR uses dialects to quote the field names, too.

Reported Error Scenario (MySQL case)

scala> val url="jdbc:mysql://localhost:3306/temp"
scala> val prop = new java.util.Properties
scala> prop.setProperty("user","root")
scala> spark.createDataset(Seq("a","b","c")).toDF("order")
scala> df.write.mode("overwrite").jdbc(url, "temptable", prop)
...MySQLSyntaxErrorException: ... near 'order TEXT )

How was this patch tested?

Pass the Jenkins tests and manually do the above case.

@SparkQA
Copy link

SparkQA commented Jul 8, 2016

Test build #61996 has finished for PR 14107 at commit 4f63716.

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

@rxin
Copy link
Contributor

rxin commented Jul 8, 2016

Merging in master/2.0.

asfgit pushed a commit that referenced this pull request Jul 8, 2016
## What changes were proposed in this pull request?

Currently, JDBC Writer uses dialects to get datatypes, but doesn't to quote field names. This PR uses dialects to quote the field names, too.

**Reported Error Scenario (MySQL case)**
```scala
scala> val url="jdbc:mysql://localhost:3306/temp"
scala> val prop = new java.util.Properties
scala> prop.setProperty("user","root")
scala> spark.createDataset(Seq("a","b","c")).toDF("order")
scala> df.write.mode("overwrite").jdbc(url, "temptable", prop)
...MySQLSyntaxErrorException: ... near 'order TEXT )
```

## How was this patch tested?

Pass the Jenkins tests and manually do the above case.

Author: Dongjoon Hyun <[email protected]>

Closes #14107 from dongjoon-hyun/SPARK-16387.

(cherry picked from commit 3b22291)
Signed-off-by: Reynold Xin <[email protected]>
@asfgit asfgit closed this in 3b22291 Jul 8, 2016
@dongjoon-hyun
Copy link
Member Author

Oh, super fast! Thank you.

zzcclp added a commit to zzcclp/spark that referenced this pull request Jul 13, 2016
@dongjoon-hyun dongjoon-hyun deleted the SPARK-16387 branch July 20, 2016 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants