Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check all expression
  • Loading branch information
ulysses-you committed Jul 3, 2020
commit 0798fca28a22595752d7ccec3030b44ccafdb3ff
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ trait CheckAnalysis extends PredicateHelper {
case g: GroupingID =>
failAnalysis("grouping_id() can only be used with GroupingSets/Cube/Rollup")

case Alias(w: WindowFunction, _) =>
case e: Expression if e.children.exists(_.isInstanceOf[WindowFunction]) &&
!e.isInstanceOf[WindowExpression] =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent

val w = e.children.find(_.isInstanceOf[WindowFunction]).get
failAnalysis(s"Window function $w requires an OVER clause.")

case w @ WindowExpression(AggregateExpression(_, _, true, _, _), _) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,5 +888,11 @@ class AnalysisSuite extends AnalysisTest with Matchers {
test("throw user facing error when use WindowFunction directly") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a JIRA prefix here? SPARK-31975: ...

assertAnalysisError(testRelation2.select(RowNumber()),
Seq("Window function row_number() requires an OVER clause."))

assertAnalysisError(testRelation2.select(Sum(RowNumber())),
Seq("Window function row_number() requires an OVER clause."))

assertAnalysisError(testRelation2.select(RowNumber() + 1),
Seq("Window function row_number() requires an OVER clause."))
}
}