Skip to content

Commit

Permalink
Revert "Update the error message if column doesn't exist in projection"
Browse files Browse the repository at this point in the history
This reverts commit 8b362f2.
  • Loading branch information
Hazel-Datastax committed Dec 20, 2024
1 parent 8b362f2 commit 35f0da4
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public ProjectionException(ErrorInstance errorInstance) {
}

public enum Code implements ErrorCode<ProjectionException> {
UNSUPPORTED_COLUMN_TYPES,
UNKNOWN_TABLE_COLUMNS;
UNSUPPORTED_COLUMN_TYPES;

private final ErrorTemplate<ProjectionException> template;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,8 @@ public static <CmdT extends Projectable> TableProjection fromDefinition(

// TODO: A table can't be with empty columns. Think a redundant check.
if (columns.isEmpty()) {
throw ProjectionException.Code.UNKNOWN_TABLE_COLUMNS.get(
errVars(
table,
map -> {
map.put("allColumns", errFmtApiColumnDef(table.apiTableDef().allColumns()));
map.put(
"unknownColumns",
command.tableProjectionDefinition().getColumnNames().toString());
}));
throw ErrorCodeV1.UNSUPPORTED_PROJECTION_DEFINITION.toApiException(
"did not include any Table columns");
}

// result set has ColumnDefinitions not ColumnMetadata kind of weird
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ private TableProjectionDefinition(boolean inclusion, List<String> columnNames) {
this.columnNames = columnNames;
}

/**
* Return the column defined in the projection.
*
* @return a new {@code ArrayList} containing the column names.
*/
public List<String> getColumnNames() {
return new ArrayList<>(columnNames);
}

public static TableProjectionDefinition createFromDefinition(JsonNode projectionDefinition) {
// First special case: "simple" default projection; "include all"
if (projectionDefinition == null || projectionDefinition.isEmpty()) {
Expand Down
11 changes: 0 additions & 11 deletions src/main/resources/errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -619,17 +619,6 @@ request-errors:
Resend the command using only supported column types.
- scope: PROJECTION
code: UNKNOWN_TABLE_COLUMNS
title: Columns in the projection are not defined in the table schema
body: |-
Only columns defined in the table schema can be included in the projection.
The table ${keyspace}.${table} defines the columns: ${allColumns}.
The projection included the following unknown columns: ${unknownColumns}.
${SNIPPET.RESEND_USING_ONLY_DEFINED_COLUMNS}
# ================================================================================================================
# Family: REQUEST Scope: SCHEMA
# ================================================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.stargate.sgv2.jsonapi.api.model.command.CommandName;
import io.stargate.sgv2.jsonapi.api.v1.util.DataApiResponseValidator;
import io.stargate.sgv2.jsonapi.api.v1.util.scenarios.AllScalarTypesTableScenario;
import io.stargate.sgv2.jsonapi.exception.ProjectionException;
import io.stargate.sgv2.jsonapi.fixtures.types.ApiDataTypesForTesting;
import io.stargate.sgv2.jsonapi.service.schema.tables.ApiColumnDefContainer;
import io.stargate.sgv2.jsonapi.service.schema.tables.ApiDataTypeDefs;
Expand Down Expand Up @@ -144,19 +143,6 @@ public void findManyProjectionMissingColumns() {
.doesNotHaveProjectionSchemaWith("MISSING_COLUMN");
}

@Test
public void findProjectionUnknownColumns() {

// Select a column that does not exist, should not be in the projection schema
assertTableCommand(keyspaceName, TABLE_NAME)
.templated()
.find(Map.of("id", "row-1"), List.of("FAKE2", "FAKE1"), Map.of(), Map.of())
.hasSingleApiError(
ProjectionException.Code.UNKNOWN_TABLE_COLUMNS,
ProjectionException.class,
"The projection included the following unknown columns: [FAKE2, FAKE1]");
}

private DataApiResponseValidator assertProjectionSchema(
DataApiResponseValidator validator, ApiColumnDefContainer columns) {
columns.values().forEach(validator::hasProjectionSchemaWith);
Expand Down

0 comments on commit 35f0da4

Please sign in to comment.