-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-31975][SQL] Show AnalysisException when WindowFunction is used without WindowExpression #28808
Changes from 4 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.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed. |
||
|
||
case w @ WindowExpression(AggregateExpression(_, _, true, _, _), _) => | ||
failAnalysis(s"Distinct window functions are not supported: $w") | ||
|
||
|
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") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we add a JIRA prefix here? |
||
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 withoutover
it 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.