Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/13701#discussion_r68353312
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala
---
@@ -85,8 +85,15 @@ private[sql] object FileSourceStrategy extends Strategy
with Logging {
ExpressionSet(normalizedFilters.filter(_.references.subsetOf(partitionSet)))
logInfo(s"Pruning directories with:
${partitionKeyFilters.mkString(",")}")
- val dataColumns =
- l.resolve(fsRelation.dataSchema,
fsRelation.sparkSession.sessionState.analyzer.resolver)
+ val dataColumns = l.resolve(fsRelation.dataSchema,
+ fsRelation.sparkSession.sessionState.analyzer.resolver).map { c =>
+ fsRelation.dataSchema.find(_.name == c.name).map { f =>
+ c match {
+ case a: AttributeReference => a.withMetadata(f.metadata)
+ case _ => c
+ }
+ }.getOrElse(c)
+ }
--- End diff --
We use metadata in merged schema to mark the optional field (not existing
in all partitions), the metadata is lost after resolving. If we don't add them
back, the pushed-down filters will be failed due to non existing field error.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]