cloud-fan commented on code in PR #35866:
URL: https://github.com/apache/spark/pull/35866#discussion_r844769284
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasingSuite.scala:
##########
@@ -812,6 +812,40 @@ class NestedColumnAliasingSuite extends SchemaPruningTest {
val expected3 =
contact.select($"name").rebalance($"name").select($"name.first").analyze
comparePlans(optimized3, expected3)
}
+
+ test("SPARK-38530: Do not push down nested ExtractValues with other
expressions") {
+ val inputType = StructType.fromDDL(
+ "a int, b struct<c: array<int>, c2: int>")
+ val simpleStruct = StructType.fromDDL(
+ "b struct<c: struct<d: int, e: int>, c2 int>"
+ )
+ val input = LocalRelation(
+ 'id.int,
+ 'col1.array(ArrayType(inputType)))
+
+ val query = input
+ .generate(Explode('col1))
+ .select(
+ UnresolvedExtractValue(
+ UnresolvedExtractValue(
+ CaseWhen(Seq(('col.getField("a").===(1),
+ Literal.default(simpleStruct)))),
+ Literal("b")),
+ Literal("c")).as("result"))
+ .analyze
+ val optimized = Optimize.execute(query)
+
+ // Only the inner-most col.a should be pushed down.
+ val expected = input
+ .select('col1)
+ .generate(Explode('col1.getField("a")), unrequiredChildIndex = Seq(0))
+ .select(UnresolvedExtractValue(UnresolvedExtractValue(
+ CaseWhen(Seq(('col.===(1),
Review Comment:
```suggestion
CaseWhen(Seq(('col === 1,
```
--
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]