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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/collect.scala:
##########
@@ -317,21 +317,43 @@ private[aggregate] object CollectTopK {
 case class ListAgg(
     child: Expression,
     delimiter: Expression = Literal(null),
-    orderExpressions: Seq[SortOrder] = Nil,
+    orderChildExpressions: Seq[Expression] = Nil,
+    orderDirections: Seq[SortDirection] = Nil,
+    orderNullOrderings: Seq[NullOrdering] = Nil,
+    orderSameOrderExpressions: Seq[Seq[Expression]] = Nil,
     mutableAggBufferOffset: Int = 0,
     inputAggBufferOffset: Int = 0)
   extends Collect[mutable.ArrayBuffer[Any]]
   with SupportsOrderingWithinGroup
   with ImplicitCastInputTypes {
 
+  lazy val orderExpressions: Seq[SortOrder] = 
orderChildExpressions.zipWithIndex.map {
+    case (orderChild, i) =>
+      SortOrder(
+        child = orderChild,
+        direction = if (i < orderDirections.length) orderDirections(i) else 
Ascending,
+        nullOrdering = if (i < orderNullOrderings.length) 
orderNullOrderings(i) else NullsLast,
+        sameOrderExpressions = if (i < orderSameOrderExpressions.length) {
+          orderSameOrderExpressions(i)
+        } else {
+          Seq.empty
+        }

Review Comment:
   Doesn't hitting `(i < orderNullOrderings.length)` indicate something went 
terribly wrong? There shouldn't be a normal code flow where we have different 
sizes of those lists



-- 
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