-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-31975][SQL] Show AnalysisException when WindowFunction is used without WindowExpression #28808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-31975][SQL] Show AnalysisException when WindowFunction is used without WindowExpression #28808
Changes from 3 commits
f283385
38df40a
cd8bbb2
335935f
458d457
972ae13
0798fca
3e116f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -158,6 +158,9 @@ trait CheckAnalysis extends PredicateHelper { | |||
| case g: GroupingID => | ||||
| failAnalysis("grouping_id() can only be used with GroupingSets/Cube/Rollup") | ||||
|
|
||||
| case Alias(w: WindowFunction, _) => | ||||
| failAnalysis(s"Window function '$w' call requires an OVER clause.") | ||||
|
||||
| failAnalysis(s"Window function $wf requires window to be ordered, please add ORDER BY " + |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -826,4 +826,9 @@ class AnalysisSuite extends AnalysisTest with Matchers { | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("throw user facing error when use WindowFunction directly") { | ||
|
||
| assertAnalysisError(testRelation2.select(RowNumber()), | ||
| Seq("Window function 'row_number()' call requires an OVER clause.")) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW why do we have to match the
Alias?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The right way is
Alias(WindowExpression(w: WindowFunction, _), _)and withoutoverit isAlias(w: WindowFunction, _).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then the check doesn't work for cases like
rank() + 1?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch ! we need to check all expression.