Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,10 @@ import org.apache.spark.sql.catalyst.plans.logical.{Filter, LogicalPlan, Project
import org.apache.spark.sql.catalyst.rules.Rule

object PushDownOperatorsToDataSource extends Rule[LogicalPlan] {
override def apply(
plan: LogicalPlan): LogicalPlan = plan transformUp {
override def apply(plan: LogicalPlan): LogicalPlan = plan match {
// PhysicalOperation guarantees that filters are deterministic; no need to check
case PhysicalOperation(project, newFilters, relation : DataSourceV2Relation) =>
// merge the filters
val filters = relation.filters match {
case Some(existing) =>
existing ++ newFilters
case _ =>
newFilters
}
case PhysicalOperation(project, filters, relation: DataSourceV2Relation) =>
assert(relation.filters.isEmpty, "data source v2 should do push down only once.")

val projectAttrs = project.map(_.toAttribute)
val projectSet = AttributeSet(project.flatMap(_.references))
Expand Down Expand Up @@ -67,5 +60,7 @@ object PushDownOperatorsToDataSource extends Rule[LogicalPlan] {
} else {
filtered
}

case other => other.mapChildren(apply)
}
}