dbtsai commented on a change in pull request #23474: [SPARK-26551][SQL] Fix
schema pruning error when selecting one complex field and having is not null
predicate on another one
URL: https://github.com/apache/spark/pull/23474#discussion_r247028286
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaPruning.scala
##########
@@ -116,10 +116,28 @@ private[sql] object ParquetSchemaPruning extends
Rule[LogicalPlan] {
// For example, for a query `SELECT name.first FROM contacts WHERE name IS
NOT NULL`,
// we don't need to read nested fields of `name` struct other than `first`
field.
val (rootFields, optRootFields) = (projectionRootFields ++
filterRootFields)
- .distinct.partition(_.contentAccessed)
+ .distinct.partition(!_.prunedIfAnyChildAccessed)
optRootFields.filter { opt =>
- !rootFields.exists(_.field.name == opt.field.name)
+ val optFieldType = StructType(Array(opt.field))
Review comment:
It's not very expensive, and we only need to compute it when
`root.field.name == opt.field.name`. As a result, I feel moving it right after
`val rootFieldType` will be more readable.
```scala
root.field.name == opt.field.name && {
val rootFieldType = StructType(Array(root.field))
val optFieldType = StructType(Array(opt.field))
val merged = optFieldType.merge(rootFieldType)
merged.sameType(optFieldType)
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]