mikhailnik-db commented on code in PR #48748:
URL: https://github.com/apache/spark/pull/48748#discussion_r1840683697


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -2216,21 +2216,25 @@ class Analyzer(override val catalogManager: 
CatalogManager) extends RuleExecutor
         numArgs: Int,
         u: UnresolvedFunction): Expression = {
       func match {
-        case owg: SupportsOrderingWithinGroup if u.isDistinct =>
+        case owg: InverseDistributionFunction if u.isDistinct =>
           throw 
QueryCompilationErrors.distinctInverseDistributionFunctionUnsupportedError(
             owg.prettyName)
-        case owg: SupportsOrderingWithinGroup
+        case owg: InverseDistributionFunction
           if !owg.orderingFilled && u.orderingWithinGroup.isEmpty =>
           throw 
QueryCompilationErrors.inverseDistributionFunctionMissingWithinGroupError(
             owg.prettyName)
-        case owg: SupportsOrderingWithinGroup
+        case owg: InverseDistributionFunction

Review Comment:
   No, because I made `ListAgg` to support any number of order expressions.
   
   Plus this is a strange case, because the actual check of order expressions 
number happens in `withOrderingWithinGroup(...)` implementation. This case can 
match only `Mode` function if `mode(expr) within group (order by expr)` syntax 
is used. And that's because `mode(expr)` is equivalent to `mode() within group 
(order by expr)`, and here we actually just ban using two syntaxes 
simultaneously. I think the code and error message is quite misleading.
   
   `ListAgg` has a similar check below if `DISTINCT` is specified (see 
`QueryCompilationErrors.functionAndOrderExpressionMismatchError`). It could be 
reused  for `mode`, but it requires behavior change and I don't think it's 
worth 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.

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]

Reply via email to