cloud-fan commented on code in PR #56417:
URL: https://github.com/apache/spark/pull/56417#discussion_r3737204532
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/resolver/SortResolver.scala:
##########
@@ -135,6 +135,14 @@ class SortResolver(operatorResolver: Resolver,
expressionResolver: ExpressionRes
val resolvedChild = operatorResolver.resolve(unresolvedSort.child)
+ // ORDER BY over grouping analytics (CUBE/ROLLUP/GROUPING SETS) is not yet
supported in
+ // single-pass because the expanded Aggregate's ExprIds get out of sync
when ORDER BY
+ // inserts missing expressions. Fall back to legacy for correct results
(SPARK-57346).
+ if (operatorResolutionContextStack.current.hasGroupingAnalytics) {
Review Comment:
This guard also fires when grouping analytics exist only inside a nested
query. Subquery resolution pushes an `isSubqueryRoot` context, but
`OperatorResolutionContextStack.pop()` still propagates `hasGroupingAnalytics`
to the parent. For example, `SELECT (SELECT SUM(x) FROM VALUES (1), (2) t(x)
GROUP BY GROUPING SETS (())) AS s ORDER BY s` is rejected in pure single-pass
mode even though the outer sort is unrelated to grouping analytics. Please stop
this flag at subquery roots, or derive the guard from the direct aggregate
lineage; the same leak affects `HavingResolver`.
--
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]