Skip to content

Conversation

@szymon-miezal
Copy link

@szymon-miezal szymon-miezal commented Oct 30, 2025

What is the issue

Previously, when a table had both a SAI index (supporting OR operators) and a regular index (not supporting OR operators), queries with OR operators would fail even if the query targeted the SAI-indexed column.

What does this PR fix and why was it fixed

This patch modifies the validation to pass if at least one index supports the given filter.

CNDB PR: https://github.com/riptano/cndb/pull/15865

@github-actions
Copy link

github-actions bot commented Oct 30, 2025

Checklist before you submit for review

  • This PR adheres to the Definition of Done
  • Make sure there is a PR in the CNDB project updating the Converged Cassandra version
  • Use NoSpamLogger for log lines that may appear frequently in the logs
  • Verify test results on Butler
  • Test coverage for new/modified code is > 80%
  • Proper code formatting
  • Proper title for each commit staring with the project-issue number, like CNDB-1234
  • Each commit has a meaningful description
  • Each commit is not very long and contains related changes
  • Renames, moves and reformatting are in distinct commits
  • All new files should contain the DataStax copyright header instead of the Apache License one

@szymon-miezal szymon-miezal changed the title DSP-24966: Fix query planner to allow SAI indexes with OR operators when regular indexes present CNDB-15774: Fix query planner to allow SAI indexes with OR operators when regular indexes present Oct 30, 2025
…when regular indexes present

Previously, when a table had both a SAI index (supporting OR operators) and a
regular index (not supporting OR operators), queries with OR operators would
fail even if the query targeted the SAI-indexed column. This patch modifies the
validation to pass if at least one index supports the given filter.
@szymon-miezal szymon-miezal changed the title CNDB-15774: Fix query planner to allow SAI indexes with OR operators when regular indexes present WIP: CNDB-15774: Fix query planner to allow SAI indexes with OR operators when regular indexes present Oct 30, 2025
@szymon-miezal szymon-miezal changed the title WIP: CNDB-15774: Fix query planner to allow SAI indexes with OR operators when regular indexes present CNDB-15774: Fix query planner to allow SAI indexes with OR operators when regular indexes present Oct 30, 2025
Copy link

@adelapena adelapena left a comment

Choose a reason for hiding this comment

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

LGTM. A couple of nits that I failed to detect on the DSP ticket are the comment about both SAI and secondary indexes and the PR and commit title itself. The fix is not in the query planner but in CQL validation, so a better commit description would be Fix CQL query validation to allow SAI indexes with OR operators when regular indexes are present. These two nits can be addressed on merge.

@Test
public void shouldPickIndexWithDisjunctionSupportToServeTheQuery()
{
// given schema with both SAI and secondary indexes

Choose a reason for hiding this comment

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

Nit: both SAI and legacy/table-based is a secondary index, so I'd change this to something:

Suggested change
// given schema with both SAI and secondary indexes
// given schema with both SAI and legacy secondary indexes

or:

Suggested change
// given schema with both SAI and secondary indexes
// given schema with both SAI and table-based secondary indexes

or:

Suggested change
// given schema with both SAI and secondary indexes
// given schema with both SAI and cf-based secondary indexes

@szymon-miezal
Copy link
Author

That's right, in the DSP ticket the query planner was modified as well given I have ported a related change from CC, for this PR it's not the case anymore, good catch thank you!

@szymon-miezal szymon-miezal changed the title CNDB-15774: Fix query planner to allow SAI indexes with OR operators when regular indexes present CNDB-15774: Fix the CQL query validation to allow SAI indexes with OR operators when regular indexes present Nov 3, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2025

@cassci-bot
Copy link

❌ Build ds-cassandra-pr-gate/PR-2094 rejected by Butler


1 regressions found
See build details here


Found 1 new test failures

Test Explanation Runs Upstream
o.a.c.index.sai.cql.VectorUpdateDeleteTest.rangeDeletedInOtherSSTablesTest[ca] (compression) REGRESSION 🔴🔵 0 / 13

No known test failures found

@szymon-miezal szymon-miezal merged commit 64db0e4 into main Nov 3, 2025
489 of 494 checks passed
@szymon-miezal szymon-miezal deleted the CNDB-15774 branch November 3, 2025 16:14
michaelsembwever pushed a commit that referenced this pull request Nov 5, 2025
…exes with OR operators when regular indexes present (#2094)

Previously, when a table had both a SAI index (supporting OR operators)
and a regular index (not supporting OR operators), queries with OR
operators would fail even if the query targeted the SAI-indexed column.

This patch modifies the validation to pass if at least one index
supports the given filter.

CNDB PR: riptano/cndb#15865
michaelsembwever pushed a commit that referenced this pull request Nov 17, 2025
…exes with OR operators when regular indexes present (#2094)

Previously, when a table had both a SAI index (supporting OR operators)
and a regular index (not supporting OR operators), queries with OR
operators would fail even if the query targeted the SAI-indexed column.

This patch modifies the validation to pass if at least one index
supports the given filter.

CNDB PR: riptano/cndb#15865
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.

4 participants