Commit 96e0f8f
[SPARK-56489][SQL] Add CURRENT_PATH() builtin expression and keywords
### What changes were proposed in this pull request?
Add the `CURRENT_PATH()` builtin function that returns the current SQL resolution search path as a comma-separated string of qualified schema names (e.g. `system.builtin,system.session,spark_catalog.default`).
Also register the grammar keywords needed by the upcoming SQL PATH feature: `CURRENT_PATH`, `CURRENT_SCHEMA`, `CURRENT_DATABASE`, `DEFAULT_PATH`, `SYSTEM_PATH`, `PATH`. `CURRENT_PATH` and `CURRENT_SCHEMA` are reserved in ANSI mode per SQL:2023; the others are non-reserved.
In non-ANSI mode, `CURRENT_PATH`, `CURRENT_DATABASE`, and `CURRENT_SCHEMA` always resolve to their respective expressions (not `UnresolvedAttribute`), matching the behavior of `CURRENT_CATALOG`.
This is part 1 of the SQL PATH feature (SPARK-54810), split out to keep the review scope manageable.
### Why are the changes needed?
`CURRENT_PATH()` is a SQL-standard function (SQL:2023) that exposes the resolution search path to users. The grammar keywords are prerequisites for the `SET PATH` command and path-based resolution coming in follow-up PRs.
### Does this PR introduce _any_ user-facing change?
Yes. New builtin function `CURRENT_PATH()` and new reserved/non-reserved keywords.
### How was this patch tested?
- Added test in `FunctionQualificationSuite` verifying `current_path()` returns a non-empty qualified path string.
- Updated keyword golden files (`keywords.sql.out`, `keywords-enforced.sql.out`, `nonansi/keywords.sql.out`).
- Updated `sql-expression-schema.md` and `SparkConnectDatabaseMetaDataSuite` keyword assertions.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.6
Closes #55354 from srielau/SPARK-56489-path-syntax.
Authored-by: Serge Rielau <serge@rielau.com>
Signed-off-by: Daniel Tenedorio <daniel.tenedorio@databricks.com>1 parent 96ebbaa commit 96e0f8f
15 files changed
Lines changed: 123 additions & 8 deletions
File tree
- docs
- sql
- api/src/main
- antlr4/org/apache/spark/sql/catalyst/parser
- scala/org/apache/spark/sql
- catalyst/src/main/scala/org/apache/spark/sql/catalyst
- analysis
- expressions
- optimizer
- parser
- connect/client/jdbc/src/test/scala/org/apache/spark/sql/connect/client/jdbc
- core/src/test
- resources
- sql-functions
- sql-tests/results
- nonansi
- scala/org/apache/spark/sql
- hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| 482 | + | |
482 | 483 | | |
| 484 | + | |
| 485 | + | |
483 | 486 | | |
484 | 487 | | |
485 | 488 | | |
| |||
502 | 505 | | |
503 | 506 | | |
504 | 507 | | |
| 508 | + | |
505 | 509 | | |
506 | 510 | | |
507 | 511 | | |
| |||
671 | 675 | | |
672 | 676 | | |
673 | 677 | | |
| 678 | + | |
674 | 679 | | |
675 | 680 | | |
676 | 681 | | |
| |||
754 | 759 | | |
755 | 760 | | |
756 | 761 | | |
| 762 | + | |
757 | 763 | | |
758 | 764 | | |
759 | 765 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
201 | 202 | | |
| 203 | + | |
| 204 | + | |
202 | 205 | | |
203 | 206 | | |
204 | 207 | | |
| |||
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
| 225 | + | |
222 | 226 | | |
223 | 227 | | |
224 | 228 | | |
| |||
389 | 393 | | |
390 | 394 | | |
391 | 395 | | |
| 396 | + | |
392 | 397 | | |
393 | 398 | | |
394 | 399 | | |
| |||
474 | 479 | | |
475 | 480 | | |
476 | 481 | | |
| 482 | + | |
477 | 483 | | |
478 | 484 | | |
479 | 485 | | |
| |||
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1297 | 1297 | | |
1298 | 1298 | | |
1299 | 1299 | | |
1300 | | - | |
| 1300 | + | |
1301 | 1301 | | |
1302 | 1302 | | |
1303 | 1303 | | |
| |||
1961 | 1961 | | |
1962 | 1962 | | |
1963 | 1963 | | |
| 1964 | + | |
1964 | 1965 | | |
1965 | 1966 | | |
1966 | 1967 | | |
| |||
1977 | 1978 | | |
1978 | 1979 | | |
1979 | 1980 | | |
| 1981 | + | |
1980 | 1982 | | |
1981 | 1983 | | |
1982 | 1984 | | |
| |||
2112 | 2114 | | |
2113 | 2115 | | |
2114 | 2116 | | |
| 2117 | + | |
2115 | 2118 | | |
2116 | 2119 | | |
2117 | 2120 | | |
| |||
2187 | 2190 | | |
2188 | 2191 | | |
2189 | 2192 | | |
| 2193 | + | |
2190 | 2194 | | |
2191 | 2195 | | |
2192 | 2196 | | |
| |||
2342 | 2346 | | |
2343 | 2347 | | |
2344 | 2348 | | |
| 2349 | + | |
2345 | 2350 | | |
| 2351 | + | |
| 2352 | + | |
2346 | 2353 | | |
2347 | 2354 | | |
2348 | 2355 | | |
| |||
2362 | 2369 | | |
2363 | 2370 | | |
2364 | 2371 | | |
| 2372 | + | |
2365 | 2373 | | |
2366 | 2374 | | |
2367 | 2375 | | |
| |||
2524 | 2532 | | |
2525 | 2533 | | |
2526 | 2534 | | |
| 2535 | + | |
2527 | 2536 | | |
2528 | 2537 | | |
2529 | 2538 | | |
| |||
2604 | 2613 | | |
2605 | 2614 | | |
2606 | 2615 | | |
| 2616 | + | |
2607 | 2617 | | |
2608 | 2618 | | |
2609 | 2619 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4412 | 4412 | | |
4413 | 4413 | | |
4414 | 4414 | | |
| 4415 | + | |
| 4416 | + | |
| 4417 | + | |
| 4418 | + | |
| 4419 | + | |
| 4420 | + | |
| 4421 | + | |
| 4422 | + | |
4415 | 4423 | | |
4416 | 4424 | | |
4417 | 4425 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
| 857 | + | |
857 | 858 | | |
858 | 859 | | |
859 | 860 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
252 | 274 | | |
253 | 275 | | |
254 | 276 | | |
| |||
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
151 | | - | |
| 152 | + | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
| 172 | + | |
| 173 | + | |
166 | 174 | | |
167 | 175 | | |
168 | 176 | | |
| |||
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3434 | 3434 | | |
3435 | 3435 | | |
3436 | 3436 | | |
| 3437 | + | |
| 3438 | + | |
3437 | 3439 | | |
3438 | 3440 | | |
3439 | 3441 | | |
3440 | 3442 | | |
3441 | | - | |
3442 | | - | |
3443 | | - | |
3444 | | - | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
3445 | 3451 | | |
3446 | 3452 | | |
3447 | 3453 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
| 213 | + | |
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
0 commit comments