Commit e573644
committed
[SPARK-49054][SQL] Column default value should support current_* functions
### What changes were proposed in this pull request?
This is a regression between Spark 3.5.0 and Spark 4.
The following queries work on Spark 3.5.0 while fails on latest master branch:
```
CREATE TABLE test_current_user(i int, s string) USING parquet;
ALTER TABLE test_current_user ALTER COLUMN s SET DEFAULT current_user()
```
```
CREATE TABLE test_current_user(i int, s string default current_user()) USING parquet
INSERT INTO test_current_user (i) VALUES ((0));
```
This PR is to complete fixing this by eagerly executing finish-analysis and constant-folding rules before checking whether the expression is foldable and resolved.
### Why are the changes needed?
Bug fix
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
New UTs
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #47529 from gengliangwang/finishAnalysis.
Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>1 parent 1ec211e commit e573644
File tree
2 files changed
+30
-2
lines changed- sql
- catalyst/src/main/scala/org/apache/spark/sql/catalyst/util
- core/src/test/scala/org/apache/spark/sql
2 files changed
+30
-2
lines changedLines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
294 | 296 | | |
295 | 297 | | |
296 | 298 | | |
| |||
517 | 519 | | |
518 | 520 | | |
519 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
520 | 527 | | |
521 | 528 | | |
522 | 529 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
290 | 311 | | |
0 commit comments