[VL] Fix ValueStream empty-batch and finished-split handling#12563
Draft
malinjawi wants to merge 2 commits into
Draft
[VL] Fix ValueStream empty-batch and finished-split handling#12563malinjawi wants to merge 2 commits into
malinjawi wants to merge 2 commits into
Conversation
ValueStreamDataSource::next() had three defects: 1. Unbounded recursion: each exhausted iterator, null batch, or fully-filtered batch retried by calling next() recursively, so a long run of empty batches (e.g. a dynamic filter eliminating every row of consecutive batches) could grow the native stack without bound. The retry logic is now an iterative loop. 2. Finished-split signaling: when no iterators remain, return an explicit engaged null RowVectorPtr so TableScan reads the result as "current split finished" instead of relying on the implicit conversion of nullptr into the std::optional return type. 3. Null/zero-row batch normalization: RowVectorStream::next() converted every batch unconditionally, so a null batch from the upstream iterator would crash the conversion (a latent path given the iterator's peek-and-cache contract), and zero-row batches cost an extra scan round-trip apiece. Null and zero-row batches are now normalized to nullptr and skipped by the data source loop.
malinjawi
force-pushed
the
fix/valuestream-empty-batch
branch
from
July 19, 2026 11:06
b1878ec to
30fda50
Compare
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 are proposed in this pull request?
Three fixes in the ValueStream scan path:
ValueStreamDataSource::next()retried by calling itself — an exhausted iterator, a null batch, or a batch fully eliminated by a dynamic filter each recursed, so a long run of filtered-out batches could grow the native stack without bound. The retry is now a loop.RowVectorPtrsoTableScanreads it as "current split finished", instead of relying on the implicit conversion ofnullptrinto thestd::optionalreturn type.RowVectorStream::next()converted every batch unconditionally: a null batch from the upstream iterator would crash the conversion (latent today, given the iterator's peek-and-cache contract), and zero-row batches cost an extra scan round-trip each. Both are now normalized tonullptrand skipped by the data-source loop.Also adds the stream-index bounds check to
constructValueStreamNode()thatconstructValuesNode()andconstructCudfValueStreamNode()already perform (skipped in validation mode, where no input iterators are attached).How was this patch tested?
New cases in
ValueStreamDynamicFilterTestcover consecutive fully-filtered batches, finished-split signaling, and a filter/project pipeline over a value stream; they ride the existingvelox_operators_testtarget.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (reviewed and tested before submission)