beliefer commented on a change in pull request #30943:
URL: https://github.com/apache/spark/pull/30943#discussion_r549955100
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -2123,19 +2123,58 @@ class Analyzer(override val catalogManager:
CatalogManager)
if (isDistinct || filter.isDefined) {
throw
QueryCompilationErrors.distinctOrFilterOnlyWithAggregateFunctionError(
wf.prettyName)
+ } else if (ignoreNulls) {
+ wf match {
+ case nthValue: NthValue =>
+ nthValue.copy(ignoreNulls = ignoreNulls)
+ case _ =>
+ throw
QueryCompilationErrors.ignoreNullsWithUnsupportedFunctionError(
+ wf.prettyName)
+ }
} else {
wf
}
+ case owf: FrameLessOffsetWindowFunction =>
+ if (isDistinct || filter.isDefined) {
+ throw
QueryCompilationErrors.distinctOrFilterOnlyWithAggregateFunctionError(
+ owf.prettyName)
+ } else if (ignoreNulls) {
+ owf match {
+ case lead: Lead =>
+ lead.copy(ignoreNulls = ignoreNulls)
+ case lag: Lag =>
+ lag.copy(ignoreNulls = ignoreNulls)
+ case _ =>
+ throw
QueryCompilationErrors.ignoreNullsWithUnsupportedFunctionError(
+ owf.prettyName)
+ }
+ } else {
+ owf
+ }
// We get an aggregate function, we need to wrap it in an
AggregateExpression.
case agg: AggregateFunction =>
if (filter.isDefined && !filter.get.deterministic) {
throw
QueryCompilationErrors.nonDeterministicFilterInAggregateError
}
- AggregateExpression(agg, Complete, isDistinct, filter)
+ if (ignoreNulls) {
+ val aggFunc = agg match {
+ case first: First => first.copy(ignoreNulls =
ignoreNulls)
+ case last: Last => last.copy(ignoreNulls = ignoreNulls)
+ case _ =>
+ throw
QueryCompilationErrors.ignoreNullsWithUnsupportedFunctionError(
+ agg.prettyName)
+ }
+ AggregateExpression(aggFunc, Complete, isDistinct, filter)
+ } else {
+ AggregateExpression(agg, Complete, isDistinct, filter)
+ }
// This function is not an aggregate function, just return the
resolved one.
case other if (isDistinct || filter.isDefined) =>
Review comment:
I got it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]