HyukjinKwon commented on a change in pull request #27702: [SPARK-30955][SQL]
Exclude Generate output when aliasing in nested column pruning
URL: https://github.com/apache/spark/pull/27702#discussion_r384946240
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -3394,15 +3395,25 @@ class SQLQuerySuite extends QueryTest with
SharedSparkSession with AdaptiveSpark
}
}
- test("SPARK-30870: Column pruning shouldn't alias a nested column if it
means the whole " +
- "structure") {
- val df = sql(
- """
- |SELECT explodedvalue.field
- |FROM VALUES array(named_struct('field', named_struct('a', 1, 'b',
2))) AS (value)
- |LATERAL VIEW explode(value) AS explodedvalue
- """.stripMargin)
- checkAnswer(df, Row(Row(1, 2)) :: Nil)
+ test("SPARK-30870: Column pruning shouldn't alias a nested column for the
whole structure") {
+ withTable("t") {
+ val df = sql(
+ """
+ |SELECT value
+ |FROM VALUES array(named_struct('field', named_struct('a', 1, 'b',
2))) AS (value)
+ """.stripMargin)
+ df.write.format("parquet").saveAsTable("t")
Review comment:
Sorry if I am being dumb here but I can't fully follow why LocalRelation
matters here. How does the current fix relate to the test fix here?
If we concern about `ConvertToLocalRelation`, it seems not effective here:
```
== Parsed Logical Plan ==
'Project ['explodedvalue.field]
+- 'Generate 'explode('value), false, as, ['explodedvalue]
+- 'SubqueryAlias AS
+- 'UnresolvedInlineTable [value], [List('array('named_struct(field,
'named_struct(a, 1, b, 2))))]
== Analyzed Logical Plan ==
field: struct<a:int,b:int>
Project [explodedvalue#219.field AS field#220]
+- Generate explode(value#218), false, as, [explodedvalue#219]
+- SubqueryAlias AS
+- LocalRelation [value#218]
== Optimized Logical Plan ==
Project [explodedvalue#219.field AS field#220]
+- Generate explode(value#218), [0], false, as, [explodedvalue#219]
+- LocalRelation [value#218]
== Physical Plan ==
*(1) Project [explodedvalue#219.field AS field#220]
+- Generate explode(value#218), false, [explodedvalue#219]
+- LocalTableScan [value#218]
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]