peter-toth 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_r384955295
##########
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:
Both fixes fix the concrete SQL in SPARK-30870 independently because
- the whole structure was selected (my pr fixes it) and
- a nested column was selected from the output of a generate (this pr fixes
it).
But this PR is better for cases that contain generate as it can handle
nested field of a nested field
https://github.com/apache/spark/pull/27702/files#diff-957112380b0a2ef014abc8227d0b70acR313-R318
----------------------------------------------------------------
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]