Github user umesh9794 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17631#discussion_r150809485
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
 ---
    @@ -121,7 +121,8 @@ object JdbcUtils extends Logging {
           isCaseSensitive: Boolean,
           dialect: JdbcDialect): String = {
         val columns = if (tableSchema.isEmpty) {
    -      rddSchema.fields.map(x => 
dialect.quoteIdentifier(x.name)).mkString(",")
    +      rddSchema.fields.map(
    +        x => 
dialect.quoteIdentifier(x.name.stripPrefix("\"").stripSuffix("\""))).mkString(",")
    --- End diff --
    
    Thats a good idea. However when I tried changing the 
`dialect.quoteIdentifier` 5 tests reported failed in `JDBCSuite`. Fo example 
below test is failing for last two asserts: 
    
    ```
    test("quote column names by jdbc dialect") {
        val MySQL = JdbcDialects.get("jdbc:mysql://127.0.0.1/db")
        val Postgres = JdbcDialects.get("jdbc:postgresql://127.0.0.1/db")
        val Derby = JdbcDialects.get("jdbc:derby:db")
    
        val columns = Seq("abc", "key")
        val MySQLColumns = columns.map(MySQL.quoteIdentifier(_))
        val PostgresColumns = columns.map(Postgres.quoteIdentifier(_))
        val DerbyColumns = columns.map(Derby.quoteIdentifier(_))
        assert(MySQLColumns === Seq("`abc`", "`key`"))
        assert(PostgresColumns === Seq(""""abc"""", """"key""""))
        assert(DerbyColumns === Seq(""""abc"""", """"key""""))
      }
    ```
    We can see it is due to stripping the quotes in `dialect.quoteIdentifier`. 
Should I move ahead to fix these tests or can it break other things ? 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to