You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Deng Ziming (Jira)" <ji...@apache.org> on 2025/06/22 12:48:00 UTC

[jira] [Created] (SPARK-52545) Handle `""` as `"` in double quoted literal

Deng Ziming created SPARK-52545:
-----------------------------------

             Summary: Handle `""` as `"` in double quoted literal
                 Key: SPARK-52545
                 URL: https://issues.apache.org/jira/browse/SPARK-52545
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 4.0.0
            Reporter: Deng Ziming


 
spark.sql("""SELECT " ""aa"" " AS f1, " \"aa\" " AS f2, '""aa""' as f3""".stripMargin).show() 
+----+------+------+
|  f1|    f2|    f3|
+----+------+------+
| aa | "aa" |""aa""|
+----+------+------+
 
Below is the parse tree for ```SELECT " ""aa"" " AS f_1, " \"aa\" " AS f_2``` before change, the difference between them is weird, quote-quote should be treated as escaped quote.
!https://bytedance.larkoffice.com/space/api/box/stream/download/asynccode/?code=NDczYWY0MjRmZWE1YTg0OTgxMDdiNDYwMzUxNzY2NzhfNzRCRnFJU1hia3IwaldZUk5USlY1TzB0R0N3NTBOV1BfVG9rZW46TVVHemJmSm4zb1hMTHB4d0d5WmMxdkg1bndXXzE3NTA1OTYyOTk6MTc1MDU5OTg5OV9WNA!
 
After this change, the parse tree was changed, and the result became consistent with other databases such as MySQL.
spark.sql("""SELECT " ""aa"" " AS f1, " \"aa\" " AS f2, '""aa""' as f3""".stripMargin).show()
+------+------+------+
|    f1|    f2|    f3|
+------+------+------+
| "aa" | "aa" |""aa""|
+------+------+------+
 

Mysql: https://www.atlassian.com/data/sql/single-double-quote-and-backticks-in-mysql-queries



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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