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

index creation failure msg, usage with collection not fully indexed #879

Merged
merged 9 commits into from
Feb 20, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ public enum ErrorCode {
INVALID_QUERY("Invalid query"),
DRIVER_TIMEOUT("Driver timeout"),
DRIVER_CLOSED_CONNECTION("Driver request connection is closed"),
NO_NODE_AVAILABLE("No node was available to execute the query");
NO_NODE_AVAILABLE("No node was available to execute the query"),
NO_INDEX_ERROR("Faulty collection (missing indexes). Recommend re-creating the collection"),
COLLECTION_CREATION_ERROR(
"Collection creation failure (unable to create table). Recommend re-creating the collection");

private final String message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public final class ThrowableToErrorMapper {
if (message.contains("vector<float,")) {
message = "Mismatched vector dimension";
}
if (message.contains(
"If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING")
|| message.contains("ANN ordering by vector requires the column to be indexed")) {
Yuqi-Du marked this conversation as resolved.
Show resolved Hide resolved
return ErrorCode.NO_INDEX_ERROR
tatu-at-datastax marked this conversation as resolved.
Show resolved Hide resolved
.toApiException()
.getCommandResultError(ErrorCode.NO_INDEX_ERROR.getMessage(), Response.Status.OK);
}
return ErrorCode.INVALID_QUERY
.toApiException()
.getCommandResultError(message, Response.Status.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,17 @@ private Uni<Supplier<CommandResult>> executeCollectionCreation(QueryExecutor que
return Uni.createFrom().item(false);
}
});
return indexResult.onItem().transform(SchemaChangeResult::new);
return indexResult
.onItem()
.transform(
res -> {
if (!res) {
// table creation failure or index creation failure
return ErrorCode.COLLECTION_CREATION_ERROR.toApiException();
Yuqi-Du marked this conversation as resolved.
Show resolved Hide resolved
} else {
return new SchemaChangeResult(true);
}
});
}

/**
Expand Down
Loading