Uh oh!
There was an error while loading. Please reload this page.
[SPARK-12981][SQL] Fix Python UDF extraction for aggregation. - #10935
[SPARK-12981][SQL] Fix Python UDF extraction for aggregation.#10935xguo27 wants to merge 2 commits into
Conversation
AmplabJenkins
commented
Jan 27, 2016
Can one of the admins verify this patch? |
xguo27
commented
Feb 26, 2016
@rxin Does this fix look good to you? |
rxin
commented
Feb 27, 2016
cc @davies |
| if (plan.isInstanceOf[Aggregate]) { | ||
| transformed | ||
| } |
There was a problem hiding this comment.
a style nit: put else on the same line as the previous }
also can you add some comment explaining what's happening
xguo27
commented
Mar 1, 2016
Using these two functionally equavalent code snippets: Scala Python The logical plan comes out Scala Python We can see in Python's case, we inject an extra Project when With this fix, the logical plan generated for Python UDFs does not construct a Project if it is an Aggregate, making it consistent with its Scala counterpart, which gives correct results for ResolveAggregateFunctions to consume: After fix, Python: |
davies
commented
Apr 2, 2016
@xguo27 Thanks for working on this. I think the root cause here is that we extract Python UDFs too early (in analyzer), EvaluatePython is an special logical plan, many rules have no knowledge of it, which will break many things. We should extract Python UDFs later, in end of optimizer, or physical plan, I will send an PR to fix that. |
xguo27
commented
Apr 3, 2016
Sure @davies . I will close this PR. |
## What changes were proposed in this pull request? Currently we extract Python UDFs into a special logical plan EvaluatePython in analyzer, But EvaluatePython is not part of catalyst, many rules have no knowledge of it , which will break many things (for example, filter push down or column pruning). We should treat Python UDFs as normal expressions, until we want to evaluate in physical plan, we could extract them in end of optimizer, or physical plan. This PR extract Python UDFs in physical plan. Closes#10935 ## How was this patch tested? Added regression tests. Author: Davies Liu <davies@databricks.com> Closes#12127 from davies/py_udf.
We'ved attempted to backport the following patch for a pretty major bug in 1.6 dataframes, hopefully it works... apache#10935
When Aggregate operator being applied ExtractPythonUDFs rule, it becomes a Project. This change fixes that and maintain Aggregate operator to the original type.