cloud-fan commented on code in PR #43910:
URL: https://github.com/apache/spark/pull/43910#discussion_r1412085256
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -318,7 +319,17 @@ case class UnresolvedFunction(
override protected def withNewChildrenInternal(
newChildren: IndexedSeq[Expression]): UnresolvedFunction = {
if (filter.isDefined) {
- copy(arguments = newChildren.dropRight(1), filter =
Some(newChildren.last))
+ if (orderingWithinGroup.isDefined) {
+ val newSortOrder = Some(newChildren.last.asInstanceOf[SortOrder])
+ val args = newChildren.dropRight(1)
Review Comment:
nit: `dropRight` creates a new collection, let's more efficient here
```
val newSortOrder = Some(newChildren.last.asInstanceOf[SortOrder])
val newFilter = Some(newChildren(newChildren.length -
2).asInstanceOf[SortOrder])
... arguments = newChildren.dropRight(2)
```
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -318,7 +319,17 @@ case class UnresolvedFunction(
override protected def withNewChildrenInternal(
newChildren: IndexedSeq[Expression]): UnresolvedFunction = {
if (filter.isDefined) {
- copy(arguments = newChildren.dropRight(1), filter =
Some(newChildren.last))
+ if (orderingWithinGroup.isDefined) {
+ val newSortOrder = Some(newChildren.last.asInstanceOf[SortOrder])
+ val args = newChildren.dropRight(1)
Review Comment:
nit: `dropRight` creates a new collection, let's be more efficient here
```
val newSortOrder = Some(newChildren.last.asInstanceOf[SortOrder])
val newFilter = Some(newChildren(newChildren.length -
2).asInstanceOf[SortOrder])
... arguments = newChildren.dropRight(2)
```
--
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]