stevomitric commented on code in PR #58544:
URL: https://github.com/apache/spark/pull/58544#discussion_r4232225737
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFunctionsSuite.scala:
##########
@@ -1874,6 +1874,66 @@ class DataFrameWindowFunctionsSuite extends
SharedSparkSession
}
}
}
+
+ test("SPARK-59175: select item combining a window function with the GROUP BY
expression") {
Review Comment:
These are sql tests but the suite is `DataFrameWindowFunctionsSuite` -
aren't there more suitable places?
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -3626,6 +3628,16 @@ class Analyzer(
extractedExprMap.getOrElseUpdate(agg.canonicalized,
Alias(agg, s"_w${extractedExprMap.size}")()).toAttribute
+ // Extracts a non-window sub-expression that matches a grouping
expression as a whole
+ // (e.g. UPPER(country) when the query groups by UPPER(country)).
Without this, the
+ // transform would descend into it and extract its underlying
attributes (e.g. country),
+ // which are not part of the GROUP BY clause and would make the
child Aggregate invalid
+ // (SPARK-59175). Bare grouping attributes are left to the
`Attribute` case below.
+ case e: Expression
+ if !e.isInstanceOf[Attribute] && !e.foldable &&
!hasWindowFunction(e) &&
+ groupExpressions.exists(_.semanticEquals(e)) =>
Review Comment:
Grouping keys aliased in the DataFrame API aren't matched (because
`semanticEquals` doesn't strip aliases) - can you add some tests to validate
please?
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFunctionsSuite.scala:
##########
@@ -1874,6 +1874,66 @@ class DataFrameWindowFunctionsSuite extends
SharedSparkSession
}
}
}
+
+ test("SPARK-59175: select item combining a window function with the GROUP BY
expression") {
Review Comment:
DF tests might also be usefull
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]