-
Notifications
You must be signed in to change notification settings - Fork 537
feat: support array_contains in LabelList scalar index #5681
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
westonpace
merged 9 commits into
lance-format:main
from
fenfeng9:feat/array-contains-index-support
Jan 16, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d826391
lance-index: use LABEL_LIST index for array_contains
fenfeng9 cd07900
python: test LABEL_LIST index with array_contains
fenfeng9 61c0968
docs: clarify LABEL_LIST membership filters
fenfeng9 33558d5
test: add top-level NULL coverage and clarify scalar semantics
fenfeng9 4e697a6
Merge branch 'main' into feat/array-contains-index-support
fenfeng9 78a81b4
Merge branch 'main' into feat/array-contains-index-support
fenfeng9 bb7665d
Merge branch 'main' into feat/array-contains-index-support
fenfeng9 04669e3
Merge branch 'main' into feat/array-contains-index-support
fenfeng9 a92b939
Merge branch 'main' into feat/array-contains-index-support
fenfeng9 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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -490,6 +490,26 @@ impl ScalarQueryParser for LabelListQueryParser { | |
| if args.len() != 2 { | ||
| return None; | ||
| } | ||
| // DataFusion normalizes array_contains to array_has | ||
| if func.name() == "array_has" { | ||
| let inner_type = match data_type { | ||
| DataType::List(field) | DataType::LargeList(field) => field.data_type(), | ||
| _ => return None, | ||
| }; | ||
| let scalar = maybe_scalar(&args[1], inner_type)?; | ||
| // array_has(..., NULL) returns no matches in datafusion, but the index would | ||
| // match rows containing NULL. Fallback to match datafusion behavior. | ||
| if scalar.is_null() { | ||
| return None; | ||
| } | ||
| let query = LabelListQuery::HasAnyLabel(vec![scalar]); | ||
| return Some(IndexedExpression::index_query( | ||
| column.to_string(), | ||
| self.index_name.clone(), | ||
| Arc::new(query), | ||
| )); | ||
| } | ||
|
|
||
| let label_list = maybe_scalar(&args[1], data_type)?; | ||
| if let ScalarValue::List(list_arr) = label_list { | ||
| let list_values = list_arr.values(); | ||
|
|
@@ -1651,6 +1671,7 @@ fn visit_node( | |
| } | ||
| match expr { | ||
| Expr::Between(between) => Ok(visit_between(between, index_info)), | ||
| Expr::Alias(alias) => visit_node(alias.expr.as_ref(), index_info, depth), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch |
||
| Expr::Column(_) => Ok(visit_column(expr, index_info)), | ||
| Expr::InList(in_list) => Ok(visit_in_list(in_list, index_info)), | ||
| Expr::IsFalse(expr) => Ok(visit_is_bool(expr.as_ref(), index_info, false)), | ||
|
|
||
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.
How does this work for
array_contains? Is Datafusion mapping that toarray_hasalready?If so, can we add a comment here mentioning that this branch is also going to be hit for
array_contains?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.
Add comment