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

Can not sort table update delete #1638

Merged
merged 31 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
756f615
Use WarningException, expand CommandResultBuilder
amorton Oct 9, 2024
7cc74b5
Merge branch 'main' into ajm/warnings-full-error
amorton Oct 9, 2024
2aeb995
Merge branch 'main' into ajm/warnings-full-error
amorton Oct 9, 2024
b9cdb7f
fixes from merge
amorton Oct 9, 2024
d3a46b8
fix failing unit tests
amorton Oct 10, 2024
ad15492
fmt fix
amorton Oct 10, 2024
88c502c
fix InsertIntegrationTest$InsertManyFails.orderedFailOnBadKeyReturnDo…
amorton Oct 14, 2024
4db1c01
integration test fixes
amorton Oct 15, 2024
cd4969d
fixes for DropKeyspaceIntegrationTest
amorton Oct 15, 2024
831921d
integration test fix
amorton Oct 15, 2024
d70ec4e
BIG FIX - created wrong type of result builder
amorton Oct 15, 2024
2fdcb0b
Merge branch 'main' into ajm/warnings-full-error
amorton Oct 15, 2024
284ae2d
compile fix from merge
amorton Oct 15, 2024
4590ece
BUG FIXES and test improvements
amorton Oct 16, 2024
715b57c
Merge branch 'main' into ajm/warnings-full-error
amorton Oct 16, 2024
9c0a878
Merge branch 'main' into ajm/warnings-full-error
amorton Oct 17, 2024
b707bee
Merge branch 'main' into ajm/ann-sort-tables
amorton Oct 22, 2024
d78ad82
WIP - not compiling.
amorton Oct 22, 2024
ca68d2c
Merge branch 'main' into ajm/ann-sort-tables
amorton Oct 30, 2024
9a714f4
Working vector sort with no tests yet
amorton Oct 30, 2024
879d16d
Added integration tests
amorton Oct 31, 2024
5f5d809
fmt fix
amorton Oct 31, 2024
da2a9ee
Merge branch 'main' into ajm/ann-sort-tables
amorton Oct 31, 2024
d49464c
Merge branch 'main' into ajm/ann-sort-tables
amorton Nov 1, 2024
7a5e30d
tweak from review
amorton Nov 1, 2024
6a8e98b
init
Yuqi-Du Nov 1, 2024
5c0aeee
Merge remote-tracking branch 'origin/main' into yuqi/can-not-sort-tab…
Yuqi-Du Nov 1, 2024
65da8b7
merged from main
Yuqi-Du Nov 1, 2024
4af1cab
Merge remote-tracking branch 'origin/main' into yuqi/can-not-sort-tab…
Yuqi-Du Nov 4, 2024
a8cd346
error msg tweak
amorton Nov 5, 2024
adbd828
Merge branch 'main' into yuqi/can-not-sort-table-update-delete
Yuqi-Du Nov 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public SortException(ErrorInstance errorInstance) {

public enum Code implements ErrorCode<SortException> {
CANNOT_MIX_VECTOR_AND_NON_VECTOR_SORT,
CANNOT_SORT_TABLE_DELETE_COMMAND,
CANNOT_SORT_TABLE_UPDATE_COMMAND,
CANNOT_SORT_UNKNOWN_COLUMNS,
CANNOT_VECTOR_SORT_NON_INDEXED_VECTOR_COLUMNS,
CANNOT_VECTOR_SORT_NON_VECTOR_COLUMNS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.stargate.sgv2.jsonapi.service.resolver;

import static io.stargate.sgv2.jsonapi.exception.ErrorFormatters.errVars;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.core.instrument.MeterRegistry;
import io.stargate.sgv2.jsonapi.api.model.command.CommandContext;
Expand All @@ -9,6 +11,7 @@
import io.stargate.sgv2.jsonapi.api.v1.metrics.JsonApiMetricsConfig;
import io.stargate.sgv2.jsonapi.config.DebugModeConfig;
import io.stargate.sgv2.jsonapi.config.OperationsConfig;
import io.stargate.sgv2.jsonapi.exception.SortException;
import io.stargate.sgv2.jsonapi.service.cqldriver.executor.TableSchemaObject;
import io.stargate.sgv2.jsonapi.service.operation.*;
import io.stargate.sgv2.jsonapi.service.operation.collections.CollectionReadType;
Expand Down Expand Up @@ -65,6 +68,12 @@ public DeleteOneCommandResolver(
public Operation resolveTableCommand(
CommandContext<TableSchemaObject> ctx, DeleteOneCommand command) {

// Sort clause is not supported for table deleteOne command.
if (command.sortClause() != null && !command.sortClause().isEmpty()) {
throw SortException.Code.CANNOT_SORT_TABLE_DELETE_COMMAND.get(
errVars(ctx.schemaObject(), map -> {}));
}

var builder = new DeleteAttemptBuilder<>(ctx.schemaObject(), true);

// need to update so we use WithWarnings correctly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.stargate.sgv2.jsonapi.service.resolver;

import static io.stargate.sgv2.jsonapi.exception.ErrorFormatters.errVars;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.core.instrument.MeterRegistry;
import io.stargate.sgv2.jsonapi.api.model.command.CommandContext;
Expand All @@ -9,6 +11,7 @@
import io.stargate.sgv2.jsonapi.api.v1.metrics.JsonApiMetricsConfig;
import io.stargate.sgv2.jsonapi.config.DebugModeConfig;
import io.stargate.sgv2.jsonapi.config.OperationsConfig;
import io.stargate.sgv2.jsonapi.exception.SortException;
import io.stargate.sgv2.jsonapi.service.cqldriver.executor.TableSchemaObject;
import io.stargate.sgv2.jsonapi.service.embedding.DataVectorizerService;
import io.stargate.sgv2.jsonapi.service.operation.*;
Expand Down Expand Up @@ -79,6 +82,12 @@ public Class<UpdateOneCommand> getCommandClass() {
public Operation resolveTableCommand(
CommandContext<TableSchemaObject> ctx, UpdateOneCommand command) {

// Sort clause is not supported for table updateOne command.
if (command.sortClause() != null && !command.sortClause().isEmpty()) {
throw SortException.Code.CANNOT_SORT_TABLE_UPDATE_COMMAND.get(
errVars(ctx.schemaObject(), map -> {}));
}

var builder = new UpdateAttemptBuilder<>(ctx.schemaObject());

// need to update so we use WithWarnings correctly
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,26 @@ request-errors:

Resend the command using only vector columns that have been indexed.

- scope: SORT
code: CANNOT_SORT_TABLE_DELETE_COMMAND
title: Sort supplied for non sortable delete Table command
body: |-
The command attempted to sort a delete command running against a table.

Deleting rows in a table does not support sorting, rows can only be deleted by specifying the partition key(s) and optionally the clustering key(s) for the row(s) to be deleted.

Resend the command without the sort clause.

- scope: SORT
code: CANNOT_SORT_TABLE_UPDATE_COMMAND
title: Sort supplied for non sortable update Table command
body: |-
The command attempted to sort a update command running against a table.

Updating row in a table does not support sorting, a row can only be updated by specifying full primary key(s).

Resend the command without the sort clause.

# ================================================================================================================
# ================================================================================================================
# Server Errors
Expand Down