Skip to content

fix: enhance index awareness for CONTAINS, IN, and CONTAINSALL operat…#2786

Merged
robfrank merged 4 commits intomainfrom
fix/2774-byitem-index-filters
Nov 16, 2025
Merged

fix: enhance index awareness for CONTAINS, IN, and CONTAINSALL operat…#2786
robfrank merged 4 commits intomainfrom
fix/2774-byitem-index-filters

Conversation

@robfrank
Copy link
Collaborator

This pull request improves the query engine's ability to use BY-ITEM indexes for list fields with the CONTAINS, IN, and CONTAINSALL operators, not just CONTAINSANY. It also adds comprehensive tests to ensure these operators take advantage of BY-ITEM indexes, addressing a previously reported issue.

Index usage improvements for list operators:

  • Enhanced the ContainsCondition and ContainsAllCondition classes to ensure the CONTAINS and CONTAINSALL operators recognize and utilize BY-ITEM indexes when available, making queries more efficient. [1] [2]
  • Improved the InCondition class to support index usage for both normal (field IN [values]) and inverted (value IN list_field) syntaxes with BY-ITEM indexes, including correct key resolution for index lookups. [1] [2] [3]

Testing and validation:

  • Added a new test class Issue2774IndexByItemTest to verify that CONTAINS, IN, and CONTAINSALL operators use BY-ITEM indexes as expected, and to prevent regressions related to index usage for list fields.

Dependency updates:

  • Added a missing import for IndexSearchInfo in ContainsAllCondition.java to support index-aware logic.

@mergify
Copy link
Contributor

mergify bot commented Nov 16, 2025

🧪 CI Insights

Here's what we observed from your CI run for a45f279.

🟢 All jobs passed!

But CI Insights is watching 👀

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @robfrank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the query engine's ability to utilize BY-ITEM indexes for list fields, extending this optimization beyond just the CONTAINSANY operator to include CONTAINS, IN, and CONTAINSALL. This change aims to improve the performance of queries involving these operators on indexed list properties, ensuring more efficient data retrieval and addressing a previously reported issue.

Highlights

  • Enhanced Index Usage for CONTAINS and CONTAINSALL: The query engine now leverages BY-ITEM indexes for list fields when using the CONTAINS and CONTAINSALL operators, improving query efficiency.
  • Improved IN Operator Indexing: The IN operator now supports BY-ITEM index usage for both standard (field IN [values]) and inverted (value IN list_field) syntaxes, including correct key resolution.
  • Comprehensive Test Coverage: New tests have been added to validate that CONTAINS, IN, and CONTAINSALL operators correctly utilize BY-ITEM indexes, preventing regressions.
  • Dependency Update: A necessary import for IndexSearchInfo was added to ContainsAllCondition.java to support the new index-aware logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively enhances index awareness for CONTAINS, IN, and CONTAINSALL operators, which is a great improvement for query performance. The changes in ContainsCondition, ContainsAllCondition, and InCondition to support BY-ITEM indexes are logical and well-structured. The addition of Issue2774IndexByItemTest with comprehensive test cases is excellent for ensuring correctness and preventing future regressions.

I've found a couple of potential issues that could lead to runtime errors or prevent the index from being used as intended. Please see my detailed comments below.

@codacy-production
Copy link

codacy-production bot commented Nov 16, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.04% 84.38%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (77cb8a2) 73255 46704 63.76%
Head commit (a45f279) 73287 (+32) 46753 (+49) 63.79% (+0.04%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#2786) 32 27 84.38%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

robfrank and others added 3 commits November 16, 2025 01:39
…Condition.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
….java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@robfrank robfrank linked an issue Nov 16, 2025 that may be closed by this pull request
@robfrank robfrank added this to the 25.11.1 milestone Nov 16, 2025
@robfrank robfrank merged commit 0f20f15 into main Nov 16, 2025
20 of 22 checks passed
@robfrank robfrank deleted the fix/2774-byitem-index-filters branch November 16, 2025 11:04
robfrank added a commit that referenced this pull request Feb 11, 2026
…ions (#2786)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
(cherry picked from commit 0f20f15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL: Filters not using BY-ITEM index

1 participant