Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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, _) =>
Copy link
Contributor

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?

Copy link
Contributor Author

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 without over it is Alias(w: WindowFunction, _).

Copy link
Contributor

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?

Copy link
Contributor Author

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.

failAnalysis(s"Expression '$w' not supported without a window function.")

case w @ WindowExpression(AggregateExpression(_, _, true, _, _), _) =>
failAnalysis(s"Distinct window functions are not supported: $w")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,4 +826,9 @@ 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("Expression 'row_number()' not supported without a window function."))
}
}