[ https://issues.apache.org/jira/browse/SPARK-18123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15613088#comment-15613088 ]
Dongjoon Hyun edited comment on SPARK-18123 at 10/27/16 8:20 PM: ----------------------------------------------------------------- Hi, [~zwu....@gmail.com]. There are two related things about this. Actually, current implementation supports the followings. - Allow reserved keyword as a field name, e.g., 'order'. - Allow mixed-case data frame like the following, e.g., `[a: int, A: int]`. {code} scala> val df = sql("select 1 a, 1 A") df: org.apache.spark.sql.DataFrame = [a: int, A: int] scala> val option = Map("url" -> "jdbc:postgresql:postgres", "dbtable" -> "mixed", "user" -> "postgres", "password" -> "test") scala> df.write.mode("overwrite").format("jdbc").options(option).save() scala> df.write.mode("append").format("jdbc").options(option).save() {code} Your case should be supported without any regression the above cases. Your case might be the following. {code} val df1 = sql("select 1 a") val df2 = sql("select 1 A") val option = Map("url" -> "jdbc:postgresql:postgres", "dbtable" -> "tx", "user" -> "postgres", "password" -> "test") df1.write.mode("overwrite").format("jdbc").options(option).save() df2.write.mode("append").format("jdbc").options(option).save() {code} I'm testing more cases to solve all three cases including yours. was (Author: dongjoon): Hi, [~zwu....@gmail.com]. There is two related things about this. Actually, current implementation supports the followings. - Allow reserved keyword as a field name, e.g., 'order'. - Allow mixed-case data frame like the following. {code} scala> val df = sql("select 1 a, 1 A") df: org.apache.spark.sql.DataFrame = [a: int, A: int] scala> val option = Map("url" -> "jdbc:postgresql:postgres", "dbtable" -> "mixed", "user" -> "postgres", "password" -> "test") scala> df.write.mode("overwrite").format("jdbc").options(option).save() scala> df.write.mode("append").format("jdbc").options(option).save() {code} Your case should be supported without any regression the above cases. Your case might be the following. {code} val df1 = sql("select 1 a") val df2 = sql("select 1 A") val option = Map("url" -> "jdbc:postgresql:postgres", "dbtable" -> "tx", "user" -> "postgres", "password" -> "test") df1.write.mode("overwrite").format("jdbc").options(option).save() df2.write.mode("append").format("jdbc").options(option).save() {code} I'm testing more cases to solve all three cases including yours. > org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils.saveTable the case > senstivity issue > ---------------------------------------------------------------------------------------------- > > Key: SPARK-18123 > URL: https://issues.apache.org/jira/browse/SPARK-18123 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.0.1 > Reporter: Paul Wu > > Blindly quoting every field name for inserting is the issue (Line 110-119, > https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala). > /** > * Returns a PreparedStatement that inserts a row into table via conn. > */ > def insertStatement(conn: Connection, table: String, rddSchema: StructType, > dialect: JdbcDialect) > : PreparedStatement = { > val columns = rddSchema.fields.map(x => > dialect.quoteIdentifier(x.name)).mkString(",") > val placeholders = rddSchema.fields.map(_ => "?").mkString(",") > val sql = s"INSERT INTO $table ($columns) VALUES ($placeholders)" > conn.prepareStatement(sql) > } > This code causes the following issue (it does not happen to 1.6.x): > I have issue with the saveTable method in Spark 2.0/2.0.1. I tried to save a > dataset to Oracle database, but the fields must be uppercase to succeed. This > is not an expected behavior: If only the table names were quoted, this > utility should concern the case sensitivity. The code below throws the > exception: Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: > "DATETIME_gmt": invalid identifier. > String detailSQL ="select CAST('2016-09-25 17:00:00' AS TIMESTAMP) > DATETIME_gmt, '1' NODEB"; > hc.sql("set spark.sql.caseSensitive=false"); > Dataset<Row> ds = hc.sql(detailSQL); > ds.show(); > > org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils.saveTable(ds, url, > detailTable, p); -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org