You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sql-ref-literals.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ A string literal is used to specify a character string value.
43
43
44
44
***char**
45
45
46
-
One character from the character set. Use `\` to escape special characters (e.g., `'` or `\`).
46
+
One character from the character set. Use `\` to escape special characters (e.g., `'` or `\`), additionally, consecutive quotes can be used for escaping (e.g., `'S''park'` equals `'S\'park'`, `"S""park"` equals `"S\"park"`).
47
47
To represent unicode characters, use 16-bit or 32-bit unicode escape of the form `\uxxxx` or `\Uxxxxxxxx`,
48
48
where xxxx and xxxxxxxx are 16-bit and 32-bit code points in hexadecimal respectively (e.g., `\u3042` for `あ` and `\U0001F44D` for `👍`).
49
49
An ASCII character can also be represented as an octal number preceded by `\` like `\101`, which represents `A`.
@@ -62,9 +62,13 @@ The following escape sequences are recognized in regular string literals (withou
62
62
-`\%` -> `\%`;
63
63
-`\_` -> `\_`;
64
64
-`\<other char>` -> `<other char>`, skip the slash and leave the character as is.
65
+
-`""` -> `"`, skip first `"` in double-quoted string.
66
+
-`''` -> `'`, skip first `'` in single-quoted string.
65
67
66
68
The unescaping rules above can be turned off by setting the SQL config `spark.sql.parser.escapedStringLiterals` to `true`.
67
69
70
+
When consecutive quotes conflict with string concatenation, escaping takes precedence (e.g., `'a''b'` → `a'b` not `a`+`b`). To force string concatenation behavior instead, set `spark.sql.legacy.consecutiveStringLiterals.enabled` to `true`.
71
+
68
72
Chains of string literals are coalesced into a single string literal.
69
73
This can be useful when constructing strings that are too long to fit on a single line.
70
74
It also allows mixing of string literals and parameter marker into a single string literal.
0 commit comments