viirya commented on a change in pull request #31966:
URL: https://github.com/apache/spark/pull/31966#discussion_r613811717
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/SchemaPruningSuite.scala
##########
@@ -351,6 +351,41 @@ abstract class SchemaPruningSuite
}
}
+ testSchemaPruning("SPARK-34638: nested column prune on generator output") {
+ val query1 = spark.table("contacts")
+ .select(explode(col("friends")).as("friend"))
+ .select("friend.first")
+ checkScan(query1, "struct<friends:array<struct<first:string>>>")
+ checkAnswer(query1, Row("Susan") :: Nil)
+
+ // Currently we don't prune multiple field case.
+ val query2 = spark.table("contacts")
+ .select(explode(col("friends")).as("friend"))
+ .select("friend.first", "friend.middle")
+ checkScan(query2,
"struct<friends:array<struct<first:string,middle:string,last:string>>>")
+ checkAnswer(query2, Row("Susan", "Z.") :: Nil)
+
+ val query3 = spark.table("contacts")
+ .select(explode(col("friends")).as("friend"))
+ .select("friend.first", "friend.middle", "friend")
+ checkScan(query3,
"struct<friends:array<struct<first:string,middle:string,last:string>>>")
+ checkAnswer(query3, Row("Susan", "Z.", Row("Susan", "Z.", "Smith")) :: Nil)
+
+ withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+ val query4 = spark.table("contacts")
+ .select(explode(col("friends")).as("friend"))
+ .select("friend.First")
+ checkScan(query4, "struct<friends:array<struct<first:string>>>")
+ checkAnswer(query4, Row("Susan") :: Nil)
+
+ val query5 = spark.table("contacts")
+ .select(explode(col("friends")).as("friend"))
+ .select("friend.MIDDLE")
+ checkScan(query5, "struct<friends:array<struct<middle:string>>>")
+ checkAnswer(query5, Row("Z.") :: Nil)
+ }
+ }
Review comment:
Sure.
--
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]