Skip to content
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

Fix EqBehavior bug introduced by #1434 #1614

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,21 @@ protected Restriction newEQRestriction(TableMetadata table, VariableSpecificatio
return new SingleColumnRestriction.EQRestriction(columnDef, term);

// the index is configured to transform EQ into MATCH for backwards compatibility
var matchIndexName = ebi.matchIndex.getIndexMetadata() == null ? "Unknown" : ebi.matchIndex.getIndexMetadata().name;
if (ebi.behavior == IndexRegistry.EqBehavior.MATCH)
{
ClientWarn.instance.warn(String.format(AnalyzerEqOperatorSupport.EQ_RESTRICTION_ON_ANALYZED_WARNING,
columnDef.toString(),
matchIndexName),
ebi.matchIndex.getIndexMetadata().name),
columnDef);
return new SingleColumnRestriction.AnalyzerMatchesRestriction(columnDef, term);
}

// multiple indexes support EQ, this is unsupported
assert ebi.behavior == IndexRegistry.EqBehavior.AMBIGUOUS;
var eqIndexName = ebi.eqIndex.getIndexMetadata() == null ? "Unknown" : ebi.eqIndex.getIndexMetadata().name;
throw invalidRequest(AnalyzerEqOperatorSupport.EQ_AMBIGUOUS_ERROR,
columnDef.toString(),
matchIndexName,
eqIndexName);
ebi.matchIndex.getIndexMetadata().name,
ebi.eqIndex.getIndexMetadata().name);
}
List<? extends ColumnSpecification> receivers = toReceivers(columnDef);
Term entryKey = toTerm(Collections.singletonList(receivers.get(0)), mapKey, table.keyspace, boundNames);
Expand Down
5 changes: 4 additions & 1 deletion src/java/org/apache/cassandra/index/IndexRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,11 @@ default EqBehaviorIndexes getEqBehavior(ColumnMetadata cm)
{
boolean supportsEq = index.supportsExpression(cm, Operator.EQ);
boolean supportsMatches = index.supportsExpression(cm, Operator.ANALYZER_MATCHES);
// This is an edge case due to the NON_DAEMON IndexRegistry, which doesn't have index metadata and
// which uses regular equality by convention.
boolean hasIndexMetadata = index.getIndexMetadata() != null;

if (supportsEq && supportsMatches)
if (supportsEq && supportsMatches && hasIndexMetadata)
bothIndex = index;
else if (supportsEq)
eqOnlyIndex = index;
Expand Down
Loading