pan3793 commented on code in PR #52474:
URL: https://github.com/apache/spark/pull/52474#discussion_r2393912155
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/AliasAwareOutputExpression.scala:
##########
@@ -128,6 +128,9 @@ trait AliasAwareQueryOutputOrdering[T <: QueryPlan[T]]
}
}
}
- newOrdering.takeWhile(_.isDefined).flatten.toSeq
+ newOrdering.takeWhile(_.isDefined).flatten.toSeq ++
outputExpressions.filter {
+ case Alias(child, _) => child.foldable
+ case expr => expr.foldable
+ }.map(SortOrder(_, Ascending).copy(isConstant = true))
Review Comment:
@peter-toth the Constant SortDirection sounds like a good idea, I have
updated the code to use it.
while I have tried to add only the generated attribute
```
newOrdering.takeWhile(_.isDefined).flatten.toSeq ++
outputExpressions.flatMap {
case alias @ Alias(child, _) if child.foldable =>
Some(SortOrder(alias.toAttribute, Constant))
case expr if expr.foldable =>
Some(SortOrder(expr, Constant))
case _ => None
}
```
there are two tests fail (haven't figured out the root cause)
```
[info] CachedTableSuite:
...
[info] - SPARK-36120: Support cache/uncache table with TimestampNTZ type ***
FAILED *** (43 milliseconds)
[info] AttributeSet(TIMESTAMP_NTZ '2021-01-01 00:00:00'#17739) was not
empty The optimized logical plan has missing inputs:
[info] InMemoryRelation [TIMESTAMP_NTZ '2021-01-01 00:00:00'#17776],
StorageLevel(disk, memory, deserialized, 1 replicas)
[info] +- *(1) Project [2021-01-01 00:00:00 AS TIMESTAMP_NTZ
'2021-01-01 00:00:00'#17739]
[info] +- *(1) Scan OneRowRelation[] (QueryTest.scala:241)
...
[info] - SPARK-52692: Support cache/uncache table with Time type *** FAILED
*** (58 milliseconds)
[info] AttributeSet(TIME '22:00:00'#18852) was not empty The optimized
logical plan has missing inputs:
[info] InMemoryRelation [TIME '22:00:00'#18889], StorageLevel(disk,
memory, deserialized, 1 replicas)
[info] +- *(1) Project [22:00:00 AS TIME '22:00:00'#18852]
[info] +- *(1) Scan OneRowRelation[] (QueryTest.scala:241)
...
```
--
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]