You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "akupchinskiy (via GitHub)" <gi...@apache.org> on 2025/08/16 12:39:56 UTC

[PR] fix: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

akupchinskiy opened a new pull request, #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   ## Rationale for this change
   Current CometBroadcast implementation might cause some complex plans to fail during the execution. If an execution stage involves several broadcasts and one of them corresponds to the evaluated before (ReusedExchange scenario), it might fail due to attempt to zip unaligned partitions [here](https://github.com/apache/datafusion-comet/blob/2b0e6db77b2c27bfa91eb34d0a2469d1014c20e6/spark/src/main/scala/org/apache/spark/sql/comet/operators.scala#L306) or [here](https://github.com/apache/datafusion-comet/blob/2b0e6db77b2c27bfa91eb34d0a2469d1014c20e6/spark/src/main/scala/org/apache/spark/sql/comet/operators.scala#L292).
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   Initially, I have faced it when I was trying to run TPCDS benchmark on 10-factor scaled dataset with Spark-4: multiple queries failed with a similar error. Yet, it is reproducible for 3.5 version at least (the unit test included in the PR fails if run against main branch code). 
   
   ## What changes are included in this PR?
   Basically, the fix prevents picking ReusedExchange plan as a driving RDD (one which determines the target partitions number). Also, there is a workaround for another problem with ReusedExchangeExec: [this partition alignment](https://github.com/apache/datafusion-comet/blob/2b0e6db77b2c27bfa91eb34d0a2469d1014c20e6/spark/src/main/scala/org/apache/spark/sql/comet/operators.scala#L279) simply doesn't work for already evaluated broadcasted rdds. That is why it is necessary to align all the partitions CometBatchRDD inputs serving as broadcast wrappers. After that, all RDD have the same partitions number and zipping them works with no errors.
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   ## How are these changes tested?
   Added a unit which fails against main branch; rebuilt the jar with proposed changes and rerun TPCDS-SF10 benchmark using spark-4.0  with no errors.
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on PR #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167#issuecomment-3246260793

   @viirya would you be able to look at this? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

Posted by "akupchinskiy (via GitHub)" <gi...@apache.org>.
akupchinskiy commented on PR #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167#issuecomment-3208985411

   @comphead I think I found the breaking change making it fail in spark 4: https://issues.apache.org/jira/browse/SPARK-48195


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on PR #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167#issuecomment-3246353347

   > @viirya would you be able to look at this?
   
   I will take a look but maybe not very soon.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

Posted by "akupchinskiy (via GitHub)" <gi...@apache.org>.
akupchinskiy commented on PR #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167#issuecomment-3208043464

   > Thanks @akupchinskiy I checked it failed now on main
   > 
   > ```
   > org.apache.comet.CometRuntimeException: Partition number mismatch: 3 != 4
   > ```
   > 
   > Any reason the first partition number is taken? Can it be an issue if this value would be too small/large comparing to others?
   
   I believe it just picks the first from plan traversal output which might even be undetermined at least in cases when AQE is on. In simple scenarios, there is only one non-broadcast plan in the list - so usually it is no issue. The more explicit way to reproduce it is to run  TPCDS query set on comet build for spark 4.0: ~15 queries fail with the same error,  and all of them run with no error on the patched version. I have not figured out the root cause of this regression though


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167#issuecomment-3215418351

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion-comet/pull/2167?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `31.25000%` with `11 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 34.64%. Comparing base ([`f09f8af`](https://app.codecov.io/gh/apache/datafusion-comet/commit/f09f8af64c6599255e116a376f4f008f2fd63b43?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`9c62ea5`](https://app.codecov.io/gh/apache/datafusion-comet/commit/9c62ea5c5151244b13418e733f35318684c7e4c5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 408 commits behind head on main.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/datafusion-comet/pull/2167?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...n/scala/org/apache/spark/sql/comet/operators.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2167?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fspark%2Fsql%2Fcomet%2Foperators.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9zcGFyay9zcWwvY29tZXQvb3BlcmF0b3JzLnNjYWxh) | 33.33% | [6 Missing and 4 partials :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2167?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...e/spark/sql/comet/CometBroadcastExchangeExec.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2167?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fspark%2Fsql%2Fcomet%2FCometBroadcastExchangeExec.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9zcGFyay9zcWwvY29tZXQvQ29tZXRCcm9hZGNhc3RFeGNoYW5nZUV4ZWMuc2NhbGE=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2167?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               main    #2167       +/-   ##
   =============================================
   - Coverage     56.12%   34.64%   -21.49%     
   + Complexity      976      854      -122     
   =============================================
     Files           119      143       +24     
     Lines         11743    13126     +1383     
     Branches       2251     2363      +112     
   =============================================
   - Hits           6591     4547     -2044     
   - Misses         4012     7664     +3652     
   + Partials       1140      915      -225     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/datafusion-comet/pull/2167?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: potential native broadcast failure in scenarios with ReusedExhange [datafusion-comet]

Posted by "akupchinskiy (via GitHub)" <gi...@apache.org>.
akupchinskiy commented on PR #2167:
URL: https://github.com/apache/datafusion-comet/pull/2167#issuecomment-3324690682

   The functionality of this MR got covered by recently merged https://github.com/apache/datafusion-comet/pull/2398 alongside with https://github.com/apache/datafusion-comet/pull/2420. So, the only thing worth keeping is a unit test :)
   @comphead could you take a look?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org