Commit 438c880
[SPARK-56569] Add WINDOW_FUNCTION_FRAME_NOT_ORDERED error to replace _LEGACY_ERROR_TEMP_1037
### What changes were proposed in this pull request?
The error currently reported when an `ORDER BY` is not specified for a window function which requires it belongs in the `_LEGACY_ERROR_TEMP` group. These errors should be replaced with errors with proper error conditions.
In addition, the error text was improved, with the primary improvement being the removal of `(value_expr)`. For example:
```sql
SELECT lead(t) OVER ()
FROM VALUES ('A'), ('B'), ('C') AS tbl(t)
```
**Previous Error**:
> Window function lead(t#738680, 1, null) requires window to be ordered, please add ORDER BY clause. For example SELECT lead(t#738680, 1, null)(value_expr) OVER (PARTITION BY window_partition ORDER BY window_ordering) from table.
**New Error**:
> [WINDOW_FUNCTION_FRAME_NOT_ORDERED] Window function lead requires the window to be ordered, please add an ORDER BY clause. For example: SELECT lead(tbl.t, 1, NULL) OVER (PARTITION BY window_partition ORDER BY window_ordering) FROM table. SQLSTATE: 42601
### Why are the changes needed?
Improvement for error conditions.
### Does this PR introduce _any_ user-facing change?
The error message changed for when a window function requires and order by and none was provided.
### How was this patch tested?
New tests were added and existing tests used to verify the new error class and the new format.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code 2.1.117
Closes apache#55478 from pnikic-db/window-frame-not-ordered-error-condition.
Authored-by: Petar Nikić <petar.nikic@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>1 parent 55ddfe3 commit 438c880
8 files changed
Lines changed: 68 additions & 19 deletions
File tree
- common/utils/src/main/resources/error
- sql
- catalyst/src/main/scala/org/apache/spark/sql/errors
- core/src/test
- resources/sql-tests
- analyzer-results
- udf
- inputs
- results
- udf
- scala/org/apache/spark/sql
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8542 | 8542 | | |
8543 | 8543 | | |
8544 | 8544 | | |
| 8545 | + | |
| 8546 | + | |
| 8547 | + | |
| 8548 | + | |
| 8549 | + | |
| 8550 | + | |
8545 | 8551 | | |
8546 | 8552 | | |
8547 | 8553 | | |
| |||
8813 | 8819 | | |
8814 | 8820 | | |
8815 | 8821 | | |
8816 | | - | |
8817 | | - | |
8818 | | - | |
8819 | | - | |
8820 | | - | |
8821 | 8822 | | |
8822 | 8823 | | |
8823 | 8824 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
900 | | - | |
901 | | - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
902 | 904 | | |
903 | 905 | | |
904 | 906 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
| 425 | + | |
425 | 426 | | |
426 | | - | |
| 427 | + | |
| 428 | + | |
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| |||
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | | - | |
| 619 | + | |
| 620 | + | |
620 | 621 | | |
621 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
622 | 639 | | |
623 | 640 | | |
624 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
161 | 165 | | |
162 | 166 | | |
163 | 167 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
| 425 | + | |
425 | 426 | | |
426 | | - | |
| 427 | + | |
| 428 | + | |
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| |||
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
| 603 | + | |
603 | 604 | | |
604 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
605 | 624 | | |
606 | 625 | | |
607 | 626 | | |
| |||
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
0 commit comments