Commit daa29f6
[SPARK-53573][SQL] IDENTIFIER everywhere
### What changes were proposed in this pull request?
We propose expanding the IDENTIFIER() clause, which turns a string into a qualified identifier, to all places identifiers can appear. The current clause is severely limited in where it can go because it accepts constant expressions, including session variables.
Due to the complexity of the argument the existing clause requires tricky code to incrementally analyze its arguments and then execute sections of parser code at a later point.
By contrast the generalized IDENTIFIER clause only allows string literals which can be processed in the visitor methods.
Due to the rework of parameter markers and string coalescing this allows for constructs such as:
```
SELECT * FROM IDENTIFIER(:cat '.' :schema '.' :table)
```
it even allows:
```
SELECT 'hello' AS IDENTIFIER(:alias);
```
This is really all identifier() needs. We may be able to deprecate and de-support the existing too complex identifier() implementation.
### Why are the changes needed?
IDENTIFIER() is a popular feature, but it can only be used in very specific, hard to reason about places.
The new implementation preserved 99% of teh fucntion while expanding its use to everywhere.
### Does this PR introduce _any_ user-facing change?
Yes, it's a new feature
### How was this patch tested?
expanded Parameters and inentifier-clause test suites.
### Was this patch authored or co-authored using generative AI tooling?
Yes, Clause Sonnet 4.5
Closes #52765 from srielau/identifier-lite.
Authored-by: Serge Rielau <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>1 parent 5c16a73 commit daa29f6
File tree
33 files changed
+8155
-352
lines changed- common/utils/src/main/resources/error
- sql
- api/src/main
- antlr4/org/apache/spark/sql/catalyst/parser
- scala/org/apache/spark/sql
- catalyst/parser
- errors
- internal
- catalyst/src
- main/scala/org/apache/spark/sql
- catalyst/parser
- errors
- internal
- test/scala/org/apache/spark/sql/catalyst/parser
- core/src
- main/scala/org/apache/spark/sql
- classic
- execution
- test
- resources/sql-tests
- analyzer-results
- inputs
- results
- scala/org/apache/spark/sql
- connector
- errors
- execution/datasources/v2
- jdbc
- scripting
33 files changed
+8155
-352
lines changedLines changed: 1 addition & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2064 | 2064 | | |
2065 | 2065 | | |
2066 | 2066 | | |
2067 | | - | |
| 2067 | + | |
2068 | 2068 | | |
2069 | 2069 | | |
2070 | 2070 | | |
| |||
8650 | 8650 | | |
8651 | 8651 | | |
8652 | 8652 | | |
8653 | | - | |
8654 | | - | |
8655 | | - | |
8656 | | - | |
8657 | | - | |
8658 | 8653 | | |
8659 | 8654 | | |
8660 | 8655 | | |
| |||
Lines changed: 37 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
| |||
92 | 99 | | |
93 | 100 | | |
94 | 101 | | |
95 | | - | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
128 | | - | |
| 135 | + | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
132 | | - | |
| 139 | + | |
133 | 140 | | |
134 | 141 | | |
135 | 142 | | |
| |||
144 | 151 | | |
145 | 152 | | |
146 | 153 | | |
147 | | - | |
| 154 | + | |
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
151 | 158 | | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
155 | | - | |
| 162 | + | |
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
159 | | - | |
| 166 | + | |
160 | 167 | | |
161 | 168 | | |
162 | 169 | | |
| |||
321 | 328 | | |
322 | 329 | | |
323 | 330 | | |
324 | | - | |
| 331 | + | |
325 | 332 | | |
326 | 333 | | |
327 | 334 | | |
| |||
833 | 840 | | |
834 | 841 | | |
835 | 842 | | |
836 | | - | |
837 | | - | |
| 843 | + | |
| 844 | + | |
838 | 845 | | |
839 | 846 | | |
840 | 847 | | |
| |||
1241 | 1248 | | |
1242 | 1249 | | |
1243 | 1250 | | |
1244 | | - | |
| 1251 | + | |
1245 | 1252 | | |
1246 | 1253 | | |
1247 | 1254 | | |
| |||
1297 | 1304 | | |
1298 | 1305 | | |
1299 | 1306 | | |
1300 | | - | |
| 1307 | + | |
1301 | 1308 | | |
1302 | 1309 | | |
1303 | 1310 | | |
| |||
1599 | 1606 | | |
1600 | 1607 | | |
1601 | 1608 | | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
1602 | 1619 | | |
1603 | 1620 | | |
1604 | 1621 | | |
| 1622 | + | |
1605 | 1623 | | |
1606 | 1624 | | |
1607 | 1625 | | |
1608 | 1626 | | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1609 | 1635 | | |
1610 | 1636 | | |
1611 | 1637 | | |
| |||
Lines changed: 124 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
63 | 89 | | |
64 | | - | |
| 90 | + | |
65 | 91 | | |
66 | 92 | | |
67 | 93 | | |
68 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
69 | 109 | | |
70 | 110 | | |
71 | 111 | | |
| |||
161 | 201 | | |
162 | 202 | | |
163 | 203 | | |
164 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
165 | 280 | | |
166 | 281 | | |
167 | 282 | | |
168 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
169 | 287 | | |
170 | 288 | | |
171 | 289 | | |
| |||
351 | 469 | | |
352 | 470 | | |
353 | 471 | | |
354 | | - | |
| 472 | + | |
355 | 473 | | |
356 | 474 | | |
357 | 475 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | | - | |
| 121 | + | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
434 | 442 | | |
435 | 443 | | |
436 | 444 | | |
| |||
476 | 484 | | |
477 | 485 | | |
478 | 486 | | |
| 487 | + | |
479 | 488 | | |
480 | 489 | | |
481 | 490 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
480 | | - | |
| 480 | + | |
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| 110 | + | |
109 | 111 | | |
0 commit comments