Commit 8229509
authored
refactor: Introduce SpillState enum for memory-limited NLJ execution (#21636)
## 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
<!--
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.
-->
The current approach does use Option fields as implicit state flags
(e.g., left_stream.is_some() to check if we're in memory-limited mode),
which is fragile. This introduces a dedicated enum to make the execution
state explicit.
## What changes are included in this PR?
Replace scattered Option fields and boolean flags with a dedicated
SpillState enum that explicitly tracks the fallback state:
- Disabled: fallback not possible (unsupported join type or no disk)
- Pending: fallback possible, holding left_plan and task_context for
re-execution on OOM
- Active: fallback triggered, holding all spill-related state
(left_stream, reservation, spill_manager, etc.)
This makes the state transitions explicit and eliminates the implicit
is_memory_limited() check based on Option::is_some().
Co-authored-by: Claude Code
## Are these changes tested?
<!--
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)?
-->
Existing tests
## Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->1 parent 882be98 commit 8229509
1 file changed
Lines changed: 140 additions & 151 deletions
0 commit comments