hvanhovell commented on a change in pull request #22573: [SPARK-25558][SQL]
Pushdown predicates for nested fields in DataSource Strategy
URL: https://github.com/apache/spark/pull/22573#discussion_r275846248
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
##########
@@ -442,53 +442,65 @@ object DataSourceStrategy {
* @return a `Some[Filter]` if the input [[Expression]] is convertible,
otherwise a `None`.
*/
protected[sql] def translateFilter(predicate: Expression): Option[Filter] = {
+ // Recursively try to find an attribute name from the top level that can
be pushed down.
+ def attrName(e: Expression): Option[String] = e match {
+ // In Spark and many data sources such as parquet, dots are used as a
column path delimiter;
+ // thus, we don't translate such expressions.
+ case a: Attribute if !a.name.contains(".") =>
+ Some(a.name)
+ case s: GetStructField if !s.childSchema(s.ordinal).name.contains(".") =>
+ attrName(s.child).map(_ + s".${s.childSchema(s.ordinal).name}")
Review comment:
`_ + "." + s.childSchema(s.ordinal).name`?
----------------------------------------------------------------
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]