viirya commented on a change in pull request #26978: [SPARK-29721][SQL] Prune
unnecessary nested fields from Generate without Project
URL: https://github.com/apache/spark/pull/26978#discussion_r367671380
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala
##########
@@ -155,6 +155,49 @@ object NestedColumnAliasing {
case MapType(keyType, valueType, _) => totalFieldNum(keyType) +
totalFieldNum(valueType)
case _ => 1 // UDT and others
}
+}
+
+/**
+ * This prunes unnessary nested columns from `Generate` and optional `Project`
on top
+ * of it.
+ */
+object GeneratorNestedColumnAliasing {
+ def unapply(plan: LogicalPlan): Option[LogicalPlan] = plan match {
+ case Project(projectList, g: Generate) if
(SQLConf.get.nestedPruningOnExpressions ||
+ SQLConf.get.nestedSchemaPruningEnabled) &&
canPruneGenerator(g.generator) =>
Review comment:
The logic of nested column pruning is not different between
`nestedPruningOnExpressions` and `nestedSchemaPruningEnabled`. They both need
to prune nested columns at top Project and Generate.
The difference is when `nestedSchemaPruningEnabled` is on, nested columns
will be pruned further at datasource scan node (by other rule).
It is also not different than `nestedSchemaPruningEnabled` and
`nestedPruningOnExpressions` are both on (we did this now in master). Because
when `nestedPruningOnExpressions` is on, nested columns are pruned through
Project + Generate, then `nestedSchemaPruningEnabled` is on so it gets pruned
at scan node.
----------------------------------------------------------------
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]