Skip to content

Support for LIKE expressions as PostFilter in SAI #4290

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

pranavshenoy
Copy link
Contributor

CASSANDRA-17198 Support for LIKE expression as PostFilter in SAI

Since LIKE is filtered in post filter, ALLOW FILTERING is required. I tested it with some basic queries. Will do further manual testing + unit tests. It would be helpful for early reviews.

patch by Pranav Shenoy; reviewed by Caleb Rackliffe for CASSANDRA-17198

@pranavshenoy pranavshenoy force-pushed the like-postindex-filter branch from ad0a9e0 to 76e1487 Compare August 3, 2025 00:36
Since LIKE is filtered in post filter, ALLOW FILTERING is required.
I tested it with some basic queries. Will do further manual testing + unit tests.
It would be helpful for early reviews.

patch by Pranav Shenoy; reviewed by Caleb Rackliffe for CASSANDRA-17198
if (!restriction.hasSupportingIndex(indexRegistry))
throw invalidRequest("%s restriction is only supported on properly " +
"indexed columns. %s is not valid.", operator, relation);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this has been changed already in your not-yet-pushed work, but once LIKE doesn't return true from requiresIndexing(), seems like this change should no longer be necessary.

public static boolean matches(ByteBuffer buffer1, ByteBuffer buffer2)
{
return buffer1.equals(buffer2);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd probably just inline this in Expression rather than having a one-line utility method.

@@ -268,6 +287,10 @@ public boolean isSatisfiedBy(ByteBuffer columnValue)

if (lower != null)
{
// Post-filtering for LIKE operators must be consistent with implementation of LIKE operators in non-SAI Allow Filtering path
if(operator.isLikeVariant())
return termMatches(value.raw, lower.value.raw);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still may need to account for things like case-insensitive search eventually, so we should be able to just fall through to validateStringValue(), which would just call termMatches() anyway?

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.

2 participants