-
Notifications
You must be signed in to change notification settings - Fork 303
chore: fix native shuffle for batches with no columns and 0 row count #3858
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
Changes from 7 commits
953919c
3a3b715
c2a8f27
dadbec0
5120fd9
dbe2bf6
88a3ece
5a04132
f64fe9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -474,4 +474,34 @@ class CometNativeShuffleSuite extends CometTestBase with AdaptiveSparkPlanHelper | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("native datafusion scan - repartition count") { | ||
| withTempPath { dir => | ||
| withSQLConf(CometConf.COMET_ENABLED.key -> "false") { | ||
| spark | ||
| .range(1000) | ||
| .selectExpr("id", "concat('name_', id) as name") | ||
| .repartition(100) | ||
| .write | ||
| .parquet(dir.toString) | ||
| } | ||
| withSQLConf( | ||
| CometConf.COMET_NATIVE_SCAN_IMPL.key -> CometConf.SCAN_NATIVE_DATAFUSION, | ||
| CometConf.COMET_EXEC_SHUFFLE_WITH_ROUND_ROBIN_PARTITIONING_ENABLED.key -> "true") { | ||
|
Comment on lines
+488
to
+490
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the issue specific to this combination of scan and shuffle?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like I am confused by the comment
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was able to reproduce the crash with both perhaps test can be slightly improved, if it confuses |
||
| val testDF = spark.read.parquet(dir.toString).repartition(10) | ||
| // Verify CometShuffleExchangeExec is in the plan | ||
| assert( | ||
| find(testDF.queryExecution.executedPlan) { | ||
| case _: CometShuffleExchangeExec => true | ||
| case _ => false | ||
| }.isDefined, | ||
| "Expected CometShuffleExchangeExec in the plan") | ||
| // Actual validation, no crash | ||
| val count = testDF.count() | ||
| assert(count == 1000) | ||
| // Ensure test df evaluated by Comet | ||
| checkSparkAnswerAndOperator(testDF) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no usage of val testDF = spark.read.parquet(dir.toString).repartition(10)
val countDF = testDF.selectExpr("count(*) as cnt")
val count = countDF.collect().head.getLong(0)
assert(count == 1000)
checkSparkAnswerAndOperator(countDF)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is intentional, yes. Count returns just Long, I can't really inject in the middle to check native plan, so do it I check that at least everything before count is native which works for this case |
||
| } | ||
| } | ||
| } | ||
| } | ||
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.
This still looks way more complicated than what I would expect. Why do we need scratch space and to write
num_rowspartition_row_indices. Why are we "partitioning" rows that don't exist?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.
Just trying CI if single partition approach doesn't break anything
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.
Its fine, shortened the PR, so shuffle steps for
countbatches