-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-32822][SQL] Change the number of partitions to zero when a range is empty with WholeStageCodegen disabled or falled back #29681
Conversation
overflow = true | ||
if (isEmptyRange) { | ||
new EmptyRDD[InternalRow](sqlContext.sparkContext) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers: There are no changes within this else
block.
The actual change is if
block above.
@@ -994,6 +994,14 @@ class PlannerSuite extends SharedSparkSession with AdaptiveSparkPlanHelper { | |||
} | |||
} | |||
} | |||
|
|||
test("Change the number of partitions to zero when a range is empty") { | |||
withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> "false") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. nit: Just in case, could you test both cases with/without whole-stage codegen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right.
@@ -395,8 +396,10 @@ case class RangeExec(range: org.apache.spark.sql.catalyst.plans.logical.Range) | |||
RangeExec(range.canonicalized.asInstanceOf[org.apache.spark.sql.catalyst.plans.logical.Range]) | |||
} | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert the unnecesary changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for the minor comments.
Test build #128403 has finished for PR 29681 at commit
|
Test build #128406 has finished for PR 29681 at commit
|
Looks good to me. |
@@ -994,6 +994,20 @@ class PlannerSuite extends SharedSparkSession with AdaptiveSparkPlanHelper { | |||
} | |||
} | |||
} | |||
|
|||
test("Change the number of partitions to zero when a range is empty") { | |||
withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> "true") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use testWithWholeStageCodegenOnAndOff
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't notice I can use it. Thanks.
Test build #128510 has finished for PR 29681 at commit
|
Thanks! Merged to master. |
What changes were proposed in this pull request?
This PR changes the behavior of RangeExec with WholeStageCodegen disabled or falled back to change the number of partitions to zero when a range is empty.
In the current master, if WholeStageCodegen effects, the number of partitions of an empty range will be changed to zero.
But it doesn't if WholeStageCodegen is disabled or falled back.
Why are the changes needed?
To archive better performance even though WholeStageCodegen disabled or falled back.
Does this PR introduce any user-facing change?
Yes. the number of partitions gotten with
getNumPartitions
for an empty range will be changed when WholeStageCodegen is disabled.How was this patch tested?
New test.