[
https://issues.apache.org/jira/browse/SPARK-62419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152062#comment-18152062
]
Ganesha S commented on SPARK-62419:
-----------------------------------
I'm working on the implementation and will raise a PR shortly.
> Prune nested fields of a struct whose fields are split between a generator
> and the query above it
> -------------------------------------------------------------------------------------------------
>
> Key: SPARK-62419
> URL: https://issues.apache.org/jira/browse/SPARK-62419
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 4.3.0
> Reporter: Ganesha S
> Priority: Major
>
> Follow-up to SPARK-62411.
> When a generator reads some fields of a struct and the query above it reads
> the rest, the optimizer keeps the whole struct in the generator's output. For
> example:
> {code:sql}
> -- doc is STRUCT<ts: STRING, items: ARRAY<INT>>
> SELECT doc.ts, item FROM t, LATERAL UNNEST(doc.items) AS u(item)
> {code}
> Only doc.ts is needed after the UNNEST, but all of doc, including the items
> array, is kept. UNNEST runs without whole-stage codegen, so doc is copied
> into every row it produces.
> Nested column pruning already handles this when the struct also has fields
> the query does not read. It skips the case where every field is read
> somewhere, because it then treats the whole struct as needed.
> Proposal: in this case, extract the fields before the generator, so that only
> the fields read above it are passed through. This applies to all generators
> that support nested column pruning.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]