Skip to content

fix: improve delete functionality with multiple OR conditions and enh…#2760

Merged
robfrank merged 2 commits intomainfrom
fix/2695-delete-with-or-expr
Nov 6, 2025
Merged

fix: improve delete functionality with multiple OR conditions and enh…#2760
robfrank merged 2 commits intomainfrom
fix/2695-delete-with-or-expr

Conversation

@robfrank
Copy link
Collaborator

@robfrank robfrank commented Nov 6, 2025

This pull request improves index selection logic in the SQL query planner and updates related tests to use more modern assertions and add new coverage for multi-index deletes. The main focus is on refining how indexes are chosen for queries, ensuring more optimal query execution, and enhancing test reliability and completeness.

Query Planner Improvements

  • Changed index selection in SelectExecutionPlanner.java to return the descriptor with the most indexed fields (using getLast() instead of getFirst()), which should improve query performance when multiple indexes are available.
  • Refactored streams for readability and consistency in both regular and full-text index descriptor collection, using multi-line formatting and .toList() for clarity.

Testing Enhancements

  • Updated assertions in DeleteStatementTest.java to use direct stream counts (result.stream().count()) and modern assertion methods (isZero()) for better readability and reliability. [1] [2]
  • Added a new test testDeleteWithMultipleOrAndMultipleIndexes to verify correct deletion behavior when multiple indexes and OR conditions are involved, improving coverage of complex delete scenarios.
  • Added missing import for Arrays to support new or updated test logic.

@robfrank robfrank added this to the 25.11.1 milestone Nov 6, 2025
@robfrank robfrank requested a review from lvca November 6, 2025 14:42
@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 focuses on enhancing the SQL query planner's efficiency by refining its index selection mechanism, ensuring that the most effective indexes are utilized for query execution. Concurrently, it significantly improves the robustness and coverage of the test suite, particularly for complex delete operations involving multiple conditions and indexes, by modernizing existing assertions and adding new, targeted test cases.

Highlights

  • Query Planner Optimization: Modified the index selection logic in SelectExecutionPlanner.java to prioritize indexes with the most indexed fields, aiming to improve query performance by selecting a more optimal index.
  • Code Readability: Refactored stream operations in SelectExecutionPlanner.java for both regular and full-text index descriptor collection, improving readability and consistency through multi-line formatting and explicit .toList() calls.
  • Testing Modernization: Updated assertion methods in DeleteStatementTest.java to use modern stream-based counting (result.stream().count()) and isZero() for improved clarity and reliability.
  • Enhanced Test Coverage: Introduced a new test case, testDeleteWithMultipleOrAndMultipleIndexes, to cover complex delete scenarios involving multiple OR conditions and multiple indexes, ensuring robust behavior.
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.

@mergify
Copy link
Contributor

mergify bot commented Nov 6, 2025

🧪 CI Insights

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

🟢 All jobs passed!

But CI Insights is watching 👀

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 correctly improves the index selection logic by ensuring the query planner chooses the index covering the most fields, which should enhance query performance. The accompanying changes to the test suite, including modernizing assertions and adding a new test for complex delete scenarios, effectively validate the fix and improve the overall quality of the tests. I have a couple of minor suggestions to improve code consistency and test conciseness.

Comment on lines +211 to +217
database.command("sqlscript", """
CREATE EDGE duct_duct from #1:0 to #1:1 SET from_id='1', to_id='2', swap='N';
CREATE EDGE duct_duct from #1:0 to #1:2 SET from_id='1', to_id='3', swap='N';
""");
ResultSet inserted = database.query("sql", "select from duct_duct");
assertThat(inserted.stream().count()).isEqualTo(2);

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test successfully verifies the DELETE operation's correctness up to line 209. The subsequent re-insertion of data and the final assertion seem redundant for the purpose of this test. A unit test should ideally focus on verifying a single piece of functionality. Consider removing these lines to make the test more concise and focused on its primary goal of validating the delete behavior.

…cutionPlanner.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@codacy-production
Copy link

codacy-production bot commented Nov 6, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 75e77c51 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (75e77c5) Report Missing Report Missing Report Missing
Head commit (3baf809) 73233 46681 63.74%

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 (#2760) 23 23 100.00%

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

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@robfrank robfrank merged commit 1cac4b8 into main Nov 6, 2025
18 of 21 checks passed
@robfrank robfrank deleted the fix/2695-delete-with-or-expr branch November 6, 2025 18:28
robfrank added a commit that referenced this pull request Nov 10, 2025
…nd enh… (#2760)

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

(cherry picked from commit 1cac4b8)
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: Only records that match first part of big OR expression are deleted

2 participants