[ 
https://issues.apache.org/jira/browse/SPARK-16387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17036203#comment-17036203
 ] 

Izek Greenfield commented on SPARK-16387:
-----------------------------------------

Hi [~dongjoon]

thanks for the quick response. we found that on oracle the addition of "" cause 
error in our other servers that try to read that table.

if the column name is `t_id` and you create it "t_id" if you will try to do 
`select T_ID from table` you will get an error from oracle.

from the docs on the method, it says that it will escape only reserved words 
but it actually escapes all... so I this it could be change to really escape 
only reserved words. 

Like I do in the link I put in the previous comment.

> Reserved SQL words are not escaped by JDBC writer
> -------------------------------------------------
>
>                 Key: SPARK-16387
>                 URL: https://issues.apache.org/jira/browse/SPARK-16387
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.0.0
>            Reporter: Lev
>            Assignee: Dongjoon Hyun
>            Priority: Major
>             Fix For: 2.0.0
>
>
> Here is a code (imports are omitted)
> object Main extends App {
>   val sqlSession = SparkSession.builder().config(new SparkConf().
>     setAppName("Sql Test").set("spark.app.id", "SQLTest").
>     set("spark.master", "local[2]").
>     set("spark.ui.enabled", "false")
>     .setJars(Seq("/mysql/mysql-connector-java-5.1.38.jar" ))
>   ).getOrCreate()
>   import sqlSession.implicits._
>   val localprops = new Properties
>   localprops.put("user", "xxxx")
>   localprops.put("password", "xxxx")
>   val df = sqlSession.createDataset(Seq("a","b","c")).toDF("order")
>   val writer = df.write
>   .mode(SaveMode.Append)
>   writer
>   .jdbc("jdbc:mysql://localhost:3306/test3", s"jira_test", localprops)
> }
> End error is :
> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error 
> in your SQL syntax; check the manual that corresponds to your MySQL server 
> version for the right syntax to use near 'order TEXT )' at line 1
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
> Clearly the reserved word <order> has to be quoted



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to