frankyin-factual commented on a change in pull request #28898:
URL: https://github.com/apache/spark/pull/28898#discussion_r445946556
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasingSuite.scala
##########
@@ -493,6 +491,58 @@ class NestedColumnAliasingSuite extends SchemaPruningTest {
comparePlans(optimized3, expected3)
}
+ test("Nested field pruning for window functions") {
+ val spec = windowSpec($"address" :: Nil, $"id".asc :: Nil,
UnspecifiedFrame)
+ val winExpr = windowExpr(RowNumber().toAggregateExpression(), spec)
+ val query1 = contact.select($"name.first", winExpr.as('window))
+ .where($"window" === 1 && $"name.first" === "a")
+ .analyze
+ val optimized1 = Optimize.execute(query1)
+ val aliases1 = collectGeneratedAliases(optimized1)
+ val expected1 = contact
+ .select($"name.first", $"address", $"id", $"name.first".as(aliases1(1)))
+ .window(Seq(winExpr.as("window")), Seq($"address"), Seq($"id".asc))
+ .select($"first", $"${aliases1(1)}".as(aliases1(0)), $"window")
+ .where($"window" === 1 && $"${aliases1(0)}" === "a")
+ .select($"first", $"window")
+ .analyze
+ comparePlans(optimized1, expected1)
+ }
+
+ test("Nested field pruning for orderBy") {
+ val query1 = contact.select($"name.first", $"name.last")
+ .orderBy($"name.first".asc, $"name.last".asc)
+ .analyze
+ val optimized1 = Optimize.execute(query1)
+ val aliases1 = collectGeneratedAliases(optimized1)
+ val expected1 = contact
+ .select($"name.first",
+ $"name.last",
+ $"name.first".as(aliases1(0)),
+ $"name.last".as(aliases1(1)))
+ .orderBy($"${aliases1(0)}".asc, $"${aliases1(1)}".asc)
+ .select($"first", $"last")
+ .analyze
+ comparePlans(optimized1, expected1)
+ }
+
+ test("Nested field pruning for sirtBy") {
Review comment:
Yeah
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]