[SPARK-50520][PySpark] Respect timeout in df.rdd.countApprox()#56060
Open
rishav23 wants to merge 2 commits into
Open
[SPARK-50520][PySpark] Respect timeout in df.rdd.countApprox()#56060rishav23 wants to merge 2 commits into
rishav23 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
PySpark approximate RDD actions currently call getFinalValue() on the PartialResult returned by Spark approximate job APIs. This introduces blocking behavior and causes APIs like countApprox(timeout=...) to wait for full job completion instead of respecting timeout semantics. This PR changes PySpark to use PartialResult.initialValue(), which already contains the timeout-aware approximation computed by ApproximateActionListener.awaitResult(). Additionally, regression tests were added to validate:
Why are the changes needed?
Spark approximate actions are designed to return partial results after the specified timeout. Scala APIs correctly expose this behavior through PartialResult, but PySpark currently forces blocking completion by calling getFinalValue(). As a result, PySpark countApprox() ignores timeout semantics and waits for full completion.
Does this PR introduce any user-facing change?
Yes, PySpark approximate RDD actions now correctly respect timeout semantics and return timeout-aware approximate results instead of blocking until full completion.
How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
No