Repository navigation
fix: validate substrait filters that need no field pruning #8484
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
Merged
Xuanwo
merged 3 commits into
lance-format:main
from
1fanwang:fix/7805-substrait-validate-unpruned
Aug 23, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
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.
Calling this walker unconditionally makes a valid Substrait field reference panic. DataFusion 54.1 treats
root_type: Noneas a root-column reference, butremap_expr_referencesunwraps that field at line 223.Reproducer
I added this test beside the new regression test and ran
cargo test -p lance-datafusion --features substrait --lib substrait::tests::test_unpruned_selection_without_explicit_root -- --exact:At this head it panics at
substrait.rs:223withcalled Option::unwrap() on a None value. Restoring only the previous pruning guard makes the same test return columnx.Because
filter_substraitaccepts raw bytes, this turns valid input into a library panic. Please either make the traversal total—treat an omitted root asRootReferenceand return contextualInvalidInputerrors for absent optional fields—or split total validation from conditional remapping. Keep this case as a regression test.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.
The omitted-root case is fixed, but the same total/fallible traversal finding remains. Only
ifs[0]may omitthen; the current loop skips a missingthenon every clause, while DataFusion 54.1 unwraps it for every later clause.I added a regression using
IfThen { ifs: [IfClause { then: Some(...) }, IfClause { then: None }], else: None }and rancargo test -p lance-datafusion --features substrait --lib substrait::tests::test_unpruned_if_then_missing_nonleading_then -- --exact. This head panics atconsumer/expr/if_then.rs:52instead of returningInvalidInput. Please requirethenon every non-leading clause and retain that case as a regression test.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.
Fixed on
9278c302f0234589a4eaeafa3cdb70e7fa587982: the walker now permits an omittedthenonly on clause zero and returnsInvalidInputfor every later omission. The focused regression and all 88lance-datafusionlibrary tests pass, so the total/fallible traversal finding is resolved.