Uh oh!
There was an error while loading. Please reload this page.
[SPARK-21441][SQL]Incorrect Codegen in SortMergeJoinExec results failures in some cases - #18656
[SPARK-21441][SQL]Incorrect Codegen in SortMergeJoinExec results failures in some cases#18656DonnyZone wants to merge 6 commits into
Conversation
DonnyZone
commented
Jul 18, 2017
Hi, @cloud-fan, @vanzin , could you help to take a look? |
viirya
commented
Jul 18, 2017
Will CodegenFallback be used in wholestage codegen? I think it's not supported. |
DonnyZone
commented
Jul 18, 2017
Yeah, CodegenFallback just provide a fallback mode. |
No. I meant if there's a CodegenFallback expression, wholestage codegen should not be enabled. |
DonnyZone
commented
Jul 18, 2017
That's interesting, I will take a look at why the codegen is enabled |
DonnyZone
commented
Jul 18, 2017
I notice that the CollapseCodegenStages rule will still enable codegen for SortMergeJoinExec without checking CodegenFallback expressions. The logic in Actually, I'am not familiar with this part, please correct me if I get something wrong |
viirya
commented
Jul 18, 2017
I think the check for Can you try it? Thanks. |
DonnyZone
commented
Jul 18, 2017
Great! I'm also considering to disable codegen for Moreover, I just wonder whether the current pattern oder in Could you give any ideas? @davies |
DonnyZone
commented
Jul 19, 2017
I have validated both cases with and without CodegenFallback expressions for |
| case p if !supportCodegen(p) => | ||
| // collapse them recursively | ||
| InputAdapter(insertWholeStageCodegen(p)) | ||
| case j @ SortMergeJoinExec(_, _, _, _, left, right) if j.supportCodegen => |
There was a problem hiding this comment.
The previous pattern case already validates j.supportCodegen, we don't need to verify it again.
There was a problem hiding this comment.
SortMergeJoinExec.supportCodegen checks whether joinType.isInstanceOf[InnerLike]
There was a problem hiding this comment.
Therefore, I think we should still verify it.
There was a problem hiding this comment.
supportCodegen will call CodegenSupport.supportCodegen, so SortMergeJoinExec.supportCodegen is called then.
viirya
commented
Jul 19, 2017
Btw, can you also add a test for this? Thanks. |
viirya
commented
Jul 19, 2017
And please also add SQL tag to the PR title, e.g., [SPARK-21441][SQL]. Thanks. |
DonnyZone
commented
Jul 19, 2017
Thanks for reviewing, I will add a test later. |
viirya
commented
Jul 19, 2017
@cloud-fan Can you help trigger the jenkins test for this? Thanks. |
cloud-fan
commented
Jul 19, 2017
ok to test |
cloud-fan
commented
Jul 19, 2017
LGTM, can you update the PR description? |
SparkQA
commented
Jul 19, 2017
Test build #79738 has finished for PR 18656 at commit
|
LGTM for the code change. But I think we're better to have a test for this. |
SparkQA
commented
Jul 19, 2017
Test build #79749 has finished for PR 18656 at commit
|
SparkQA
commented
Jul 19, 2017
Test build #79751 has finished for PR 18656 at commit
|
…lures in some cases ## What changes were proposed in this pull request? https://issues.apache.org/jira/projects/SPARK/issues/SPARK-21441 This issue can be reproduced by the following example: ``` val spark = SparkSession .builder() .appName("smj-codegen") .master("local") .config("spark.sql.autoBroadcastJoinThreshold", "1") .getOrCreate() val df1 = spark.createDataFrame(Seq((1, 1), (2, 2), (3, 3))).toDF("key", "int") val df2 = spark.createDataFrame(Seq((1, "1"), (2, "2"), (3, "3"))).toDF("key", "str") val df = df1.join(df2, df1("key") === df2("key")) .filter("int = 2 or reflect('java.lang.Integer', 'valueOf', str) = 1") .select("int") df.show() ``` To conclude, the issue happens when: (1) SortMergeJoin condition contains CodegenFallback expressions. (2) In PhysicalPlan tree, SortMergeJoin node is the child of root node, e.g., the Project in above example. This patch fixes the logic in `CollapseCodegenStages` rule. ## How was this patch tested? Unit test and manual verification in our cluster. Author: donnyzone <wellfengzhu@gmail.com> Closes#18656 from DonnyZone/Fix_SortMergeJoinExec. (cherry picked from commit 6b6dd68) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan
commented
Jul 19, 2017
thanks, merging to master/2.2/2.1! |
…lures in some cases ## What changes were proposed in this pull request? https://issues.apache.org/jira/projects/SPARK/issues/SPARK-21441 This issue can be reproduced by the following example: ``` val spark = SparkSession .builder() .appName("smj-codegen") .master("local") .config("spark.sql.autoBroadcastJoinThreshold", "1") .getOrCreate() val df1 = spark.createDataFrame(Seq((1, 1), (2, 2), (3, 3))).toDF("key", "int") val df2 = spark.createDataFrame(Seq((1, "1"), (2, "2"), (3, "3"))).toDF("key", "str") val df = df1.join(df2, df1("key") === df2("key")) .filter("int = 2 or reflect('java.lang.Integer', 'valueOf', str) = 1") .select("int") df.show() ``` To conclude, the issue happens when: (1) SortMergeJoin condition contains CodegenFallback expressions. (2) In PhysicalPlan tree, SortMergeJoin node is the child of root node, e.g., the Project in above example. This patch fixes the logic in `CollapseCodegenStages` rule. ## How was this patch tested? Unit test and manual verification in our cluster. Author: donnyzone <wellfengzhu@gmail.com> Closes#18656 from DonnyZone/Fix_SortMergeJoinExec. (cherry picked from commit 6b6dd68) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…lures in some cases ## What changes were proposed in this pull request? https://issues.apache.org/jira/projects/SPARK/issues/SPARK-21441 This issue can be reproduced by the following example: ``` val spark = SparkSession .builder() .appName("smj-codegen") .master("local") .config("spark.sql.autoBroadcastJoinThreshold", "1") .getOrCreate() val df1 = spark.createDataFrame(Seq((1, 1), (2, 2), (3, 3))).toDF("key", "int") val df2 = spark.createDataFrame(Seq((1, "1"), (2, "2"), (3, "3"))).toDF("key", "str") val df = df1.join(df2, df1("key") === df2("key")) .filter("int = 2 or reflect('java.lang.Integer', 'valueOf', str) = 1") .select("int") df.show() ``` To conclude, the issue happens when: (1) SortMergeJoin condition contains CodegenFallback expressions. (2) In PhysicalPlan tree, SortMergeJoin node is the child of root node, e.g., the Project in above example. This patch fixes the logic in `CollapseCodegenStages` rule. ## How was this patch tested? Unit test and manual verification in our cluster. Author: donnyzone <wellfengzhu@gmail.com> Closesapache#18656 from DonnyZone/Fix_SortMergeJoinExec. (cherry picked from commit 6b6dd68) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…lures in some cases https://issues.apache.org/jira/projects/SPARK/issues/SPARK-21441 This issue can be reproduced by the following example: ``` val spark = SparkSession .builder() .appName("smj-codegen") .master("local") .config("spark.sql.autoBroadcastJoinThreshold", "1") .getOrCreate() val df1 = spark.createDataFrame(Seq((1, 1), (2, 2), (3, 3))).toDF("key", "int") val df2 = spark.createDataFrame(Seq((1, "1"), (2, "2"), (3, "3"))).toDF("key", "str") val df = df1.join(df2, df1("key") === df2("key")) .filter("int = 2 or reflect('java.lang.Integer', 'valueOf', str) = 1") .select("int") df.show() ``` To conclude, the issue happens when: (1) SortMergeJoin condition contains CodegenFallback expressions. (2) In PhysicalPlan tree, SortMergeJoin node is the child of root node, e.g., the Project in above example. This patch fixes the logic in `CollapseCodegenStages` rule. Unit test and manual verification in our cluster. Author: donnyzone <wellfengzhu@gmail.com> Closesapache#18656 from DonnyZone/Fix_SortMergeJoinExec. (cherry picked from commit 6b6dd68) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
https://issues.apache.org/jira/projects/SPARK/issues/SPARK-21441
This issue can be reproduced by the following example:
To conclude, the issue happens when:
(1) SortMergeJoin condition contains CodegenFallback expressions.
(2) In PhysicalPlan tree, SortMergeJoin node is the child of root node, e.g., the Project in above example.
This patch fixes the logic in
CollapseCodegenStagesrule.How was this patch tested?
Unit test and manual verification in our cluster.