Uh oh!
There was an error while loading. Please reload this page.
[SPARK-26147][SQL] only pull out unevaluable python udf from join condition - #23153
[SPARK-26147][SQL] only pull out unevaluable python udf from join condition#23153cloud-fan wants to merge 2 commits into
Conversation
SparkQA
commented
Nov 27, 2018
Test build #99324 has finished for PR 23153 at commit
|
| f = udf(lambda a: str(a), StringType()) | ||
| # The join condition can't be pushed down, as it refers to attributes from both sides. | ||
| # The Python UDF only refer to attributes from one side, so it's evaluable. | ||
| df = left.join(right, f("a") == col("b").cast("string"), how = "left_outer") |
| override def apply(plan: LogicalPlan): LogicalPlan = plan transformUp { | ||
| case j @ Join(_, _, joinType, condition) | ||
| if condition.isDefined && hasPythonUDF(condition.get) => | ||
| case j @ Join(_, _, joinType, Some(cond)) if hasUnevaluablePythonUDF(cond, j) => |
There was a problem hiding this comment.
Followed by the rule changes, we need modify the suites in PullOutPythonUDFInJoinConditionSuite, the suites should also construct the dummy python udf from both side.
Sorry for the mistake and thanks for the fix from Wenchen, I did this locally, the suites can be simply fixed by: |
mgaido91
commented
Nov 27, 2018
the change itself seems fine to me, as @xuanyuanking mentioned, though, we should update the existing tests. What about adding a test in the new suite checking the plans instead of a end-to-end test? |
SparkQA
commented
Nov 28, 2018
Test build #99356 has finished for PR 23153 at commit
|
cloud-fan
commented
Nov 28, 2018
retest this please |
SparkQA
commented
Nov 28, 2018
Test build #99358 has finished for PR 23153 at commit
|
cloud-fan
commented
Nov 28, 2018
thanks, merging to master/2.4! |
mgaido91
commented
Nov 28, 2018
a late LGTM as well, thanks @cloud-fan for the patch and thanks @xuanyuanking for the review. |
…dition #22326 made a mistake that, not all python UDFs are unevaluable in join condition. Only python UDFs that refer to attributes from both join side are unevaluable. This PR fixes this mistake. a new test Closes#23153 from cloud-fan/join. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit affe809) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
| private def hasUnevaluablePythonUDF(expr: Expression, j: Join): Boolean = { | ||
| expr.find { e => | ||
| PythonUDF.isScalarPythonUDF(e) && !canEvaluate(e, j.left) && !canEvaluate(e, j.right) |
There was a problem hiding this comment.
We might need a comment to explain why we only pull out the Scalar PythonUDF.
There was a problem hiding this comment.
It's only possible to have scalar UDF in join condition, so changing it to e.isInstanceOf[PythonUDF] is same.
…dition ## What changes were proposed in this pull request? apache#22326 made a mistake that, not all python UDFs are unevaluable in join condition. Only python UDFs that refer to attributes from both join side are unevaluable. This PR fixes this mistake. ## How was this patch tested? a new test Closesapache#23153 from cloud-fan/join. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…dition apache#22326 made a mistake that, not all python UDFs are unevaluable in join condition. Only python UDFs that refer to attributes from both join side are unevaluable. This PR fixes this mistake. a new test Closesapache#23153 from cloud-fan/join. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit affe809) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…dition apache#22326 made a mistake that, not all python UDFs are unevaluable in join condition. Only python UDFs that refer to attributes from both join side are unevaluable. This PR fixes this mistake. a new test Closesapache#23153 from cloud-fan/join. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit affe809) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
#22326 made a mistake that, not all python UDFs are unevaluable in join condition. Only python UDFs that refer to attributes from both join side are unevaluable.
This PR fixes this mistake.
How was this patch tested?
a new test