Skip to content

Commit

Permalink
[CORE]Fix the bug that don't pushdown mysql datasource when there are…
Browse files Browse the repository at this point in the history
… some spark-provided functions in subquery #64

This PR solved the first question about Issues[61]#61, don't `pushdown `MySQL `datasource `when there are some functions  provided by spark in subquery.
  • Loading branch information
wenfang authored and beliefer committed Nov 12, 2019
1 parent 3e18ce5 commit 3253fe5
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -474,25 +474,29 @@ class TransmitOriginalQuery(session: SparkSession) extends Rule[LogicalPlan] {
"rand",
"cast",
"like")
plan.expressions.forall {
case a: Alias =>
if (a.child.isInstanceOf[AttributeReference] || a.child.isInstanceOf[ScalarSubquery]

@inline def functionNotPushdown(plan: LogicalPlan): Boolean = {
plan.expressions.exists {
case a: Alias =>
if (a.child.isInstanceOf[AttributeReference] || a.child.isInstanceOf[ScalarSubquery]
|| a.child.isInstanceOf[BinaryArithmetic]) {
true
} else {
val func = if (a.child.isInstanceOf[AggregateExpression]) {
a.child.asInstanceOf[AggregateExpression].aggregateFunction
} else {
a.child
}
if (!pushdownFunctions.contains(func.prettyName)) {
false
} else {
true
val func = if (a.child.isInstanceOf[AggregateExpression]) {
a.child.asInstanceOf[AggregateExpression].aggregateFunction
} else {
a.child
}
if (pushdownFunctions.contains(func.prettyName)) {
false
} else {
true
}
}
}
case _ => true
case _ => false
}
}
plan.find(functionNotPushdown).isEmpty
}

/**
Expand Down

0 comments on commit 3253fe5

Please sign in to comment.