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

review for existing error messages #1713

Merged
merged 9 commits into from
Nov 14, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public DocumentException(ErrorInstance errorInstance) {
}

public enum Code implements ErrorCode<DocumentException> {
INVALID_COLUMN_VALUES,
MISSING_PRIMARY_KEY_COLUMNS,
UNKNOWN_TABLE_COLUMNS,
UNSUPPORTED_COLUMN_TYPES,
INVALID_COLUMN_VALUES,
INVALID_VECTORIZE_ON_COLUMN_WITHOUT_VECTORIZE_DEFINITION;
UNSUPPORTED_VECTORIZE_WHEN_MISSING_VECTORIZE_DEFINITION;

private final ErrorTemplate<DocumentException> template;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public FilterException(ErrorInstance errorInstance) {
}

public enum Code implements ErrorCode<FilterException> {
COMPARISON_FILTER_AGAINST_DURATION,
FILTERING_NOT_SUPPORTED_FOR_TYPE,
FILTER_REQUIRED_FOR_UPDATE_DELETE,
FULL_PRIMARY_KEY_REQUIRED_FOR_UPDATE_DELETE,
INCOMPLETE_PRIMARY_KEY_FILTER,
INVALID_FILTER,
INVALID_IN_FILTER_FOR_UPDATE_ONE_DELETE_ONE,
NON_PRIMARY_KEY_FILTER_FOR_UPDATE_DELETE,
INVALID_PRIMARY_KEY_FILTER,
MISSING_FILTER_FOR_UPDATE_DELETE,
MISSING_FULL_PRIMARY_KEY_FOR_UPDATE_DELETE,
UNKNOWN_TABLE_COLUMNS,
UNSUPPORTED_COLUMN_TYPES,
UNSUPPORTED_COMPARISON_FILTER_AGAINST_DURATION,
UNSUPPORTED_FILTERING_FOR_COLUMN_TYPES,
UNSUPPORTED_IN_FILTER_FOR_UPDATE_ONE_DELETE_ONE,
UNSUPPORTED_NON_PRIMARY_KEY_FILTER_FOR_UPDATE_DELETE,
;

private final ErrorTemplate<FilterException> template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public SchemaException(ErrorInstance errorInstance) {
}

public enum Code implements ErrorCode<SchemaException> {
CANNOT_ADD_EXISTING_COLUMNS,
CANNOT_ADD_EXISTING_INDEX,
CANNOT_ADD_EXISTING_TABLE,
CANNOT_DROP_INDEXED_COLUMNS,
Expand All @@ -25,22 +26,21 @@ public enum Code implements ErrorCode<SchemaException> {
CANNOT_DROP_VECTORIZE_FROM_UNKNOWN_COLUMNS,
CANNOT_VECTORIZE_NON_VECTOR_COLUMNS,
CANNOT_VECTORIZE_UNKNOWN_COLUMNS,
COLUMN_ALREADY_EXISTS,
DATA_TYPE_NOT_SUPPORTED_BY_INDEXING,
TEXT_ANALYSIS_NOT_SUPPORTED_BY_DATA_TYPE,
MISSING_PARTITION_COLUMNS,
UNKNOWN_DATA_TYPE,
UNKNOWN_INDEX_COLUMN,
UNKNOWN_PARTITION_COLUMNS,
UNKNOWN_PARTITION_SORT_COLUMNS,
UNKNOWN_PRIMITIVE_DATA_TYPE,
UNKNOWN_VECTOR_METRIC,
UNKNOWN_VECTOR_SOURCE_MODEL,
UNSUPPORTED_INDEXING_FOR_DATA_TYPES,
UNSUPPORTED_LIST_DEFINITION,
UNSUPPORTED_MAP_DEFINITION,
UNSUPPORTED_SET_DEFINITION,
UNSUPPORTED_TEXT_ANALYSIS_FOR_DATA_TYPES,
UNSUPPORTED_VECTOR_DIMENSION,
VECTOR_INDEX_NOT_SUPPORTED_BY_DATA_TYPE,
ZERO_PARTITION_COLUMNS,
UNSUPPORTED_VECTOR_INDEX_FOR_DATA_TYPES,

// older below - seperated because they need to be confirmed
INVALID_CONFIGURATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ 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_TOO_MUCH_DATA,
CANNOT_SORT_VECTOR_AND_NON_VECTOR_COLUMNS,
UNSUPPORTED_SORT_FOR_TABLE_DELETE_COMMAND,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in alphabetic order?

UNSUPPORTED_SORT_FOR_TABLE_UPDATE_COMMAND,
OVERLOADED_SORT_ROW_LIMIT,
CANNOT_SORT_UNKNOWN_COLUMNS,
CANNOT_VECTOR_SORT_NON_INDEXED_VECTOR_COLUMNS,
CANNOT_VECTOR_SORT_NON_VECTOR_COLUMNS,
CANNOT_VECTOR_SORT_WITH_SKIP_OPTION,
MORE_THAN_ONE_VECTOR_SORT,
MORE_THAN_ONE_VECTORIZE_SORT,
VECTORIZE_SORT_ON_NON_VECTOR_COLUMN,
VECTORIZE_SORT_ON_VECTOR_COLUMN_WITHOUT_VECTORIZE_DEFINITION;
CANNOT_SORT_ON_MULTIPLE_VECTORS,
CANNOT_SORT_ON_MULTIPLE_VECTORIZE,
CANNOT_VECTORIZE_SORT_NON_VECTOR_COLUMN,
CANNOT_VECTORIZE_SORT_WHEN_MISSING_VECTORIZE_DEFINITION;

private final ErrorTemplate<SortException> template;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public UpdateException(ErrorInstance errorInstance) {
}

public enum Code implements ErrorCode<UpdateException> {
INVALID_VECTORIZE_ON_COLUMN_WITHOUT_VECTORIZE_DEFINITION,
MISSING_UPDATE_OPERATIONS,
UNKNOWN_TABLE_COLUMNS,
UNSUPPORTED_UPDATE_OPERATION_FOR_TABLE,
UPDATE_PRIMARY_KEY_COLUMNS,
ZERO_UPDATE_OPERATIONS_FOR_TABLE;
UNSUPPORTED_UPDATE_FOR_PRIMARY_KEY_COLUMNS,
UNSUPPORTED_UPDATE_OPERATIONS_FOR_TABLE,
UNSUPPORTED_VECTORIZE_WHEN_MISSING_VECTORIZE_DEFINITION;

private final ErrorTemplate<UpdateException> template;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void accumulate(AsyncResultSet resultSet) {
// better to
// return false or throw a checked so the application can generate a better error
// message
throw SortException.Code.CANNOT_SORT_TOO_MUCH_DATA.get();
throw SortException.Code.OVERLOADED_SORT_ROW_LIMIT.get();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ private Uni<Command> vectorizeTableCommand(
tasksForVectorizeColumns(
commandContext.schemaObject(),
imc.documents(),
DocumentException.Code.INVALID_VECTORIZE_ON_COLUMN_WITHOUT_VECTORIZE_DEFINITION);
DocumentException.Code.UNSUPPORTED_VECTORIZE_WHEN_MISSING_VECTORIZE_DEFINITION);
case InsertOneCommand ioc ->
tasksForVectorizeColumns(
commandContext.schemaObject(),
List.of(ioc.document()),
DocumentException.Code.INVALID_VECTORIZE_ON_COLUMN_WITHOUT_VECTORIZE_DEFINITION);
DocumentException.Code.UNSUPPORTED_VECTORIZE_WHEN_MISSING_VECTORIZE_DEFINITION);
// Notice table update vectorize happens before UpdateCommand execution, since we can't
// do readThenUpdate for table.
// Collection update vectorize happens after the DB read.
Expand Down Expand Up @@ -275,7 +275,7 @@ private List<DataVectorizer.VectorizeTask> tasksForSort(
// clause will end up with
// thinking second one is not a vector sort, and say you can not combine vector sort and
// non-vector sort
throw SortException.Code.MORE_THAN_ONE_VECTORIZE_SORT.get(
throw SortException.Code.CANNOT_SORT_ON_MULTIPLE_VECTORIZE.get(
errVars(
tableSchemaObject,
map -> {
Expand All @@ -296,7 +296,7 @@ private List<DataVectorizer.VectorizeTask> tasksForSort(
}

if (vectorColumnDef.type().typeName() != ApiTypeName.VECTOR) {
throw SortException.Code.VECTORIZE_SORT_ON_NON_VECTOR_COLUMN.get(
throw SortException.Code.CANNOT_VECTORIZE_SORT_NON_VECTOR_COLUMN.get(
errVars(
tableSchemaObject,
map -> {
Expand All @@ -306,7 +306,7 @@ private List<DataVectorizer.VectorizeTask> tasksForSort(

var vectorTypeDef = (ApiVectorType) vectorColumnDef.type();
if (vectorTypeDef.getVectorizeDefinition() == null) {
throw SortException.Code.VECTORIZE_SORT_ON_VECTOR_COLUMN_WITHOUT_VECTORIZE_DEFINITION.get(
throw SortException.Code.CANNOT_VECTORIZE_SORT_WHEN_MISSING_VECTORIZE_DEFINITION.get(
errVars(
tableSchemaObject,
map -> {
Expand Down Expand Up @@ -343,6 +343,6 @@ private <T extends TableSchemaObject> List<DataVectorizer.VectorizeTask> taskfor
return tasksForVectorizeColumns(
tableSchemaObject,
List.of(setNode),
UpdateException.Code.INVALID_VECTORIZE_ON_COLUMN_WITHOUT_VECTORIZE_DEFINITION);
UpdateException.Code.UNSUPPORTED_VECTORIZE_WHEN_MISSING_VECTORIZE_DEFINITION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public WhereClauseWithWarnings analyse(WhereCQLClause<?> whereCQLClause) {
*/
private void checkNoFilters(Map<CqlIdentifier, TableFilter> identifierToFilter) {
if (identifierToFilter.isEmpty()) {
throw FilterException.Code.FILTER_REQUIRED_FOR_UPDATE_DELETE.get(
throw FilterException.Code.MISSING_FILTER_FOR_UPDATE_DELETE.get(
errVars(
tableSchemaObject,
map -> {
Expand All @@ -189,7 +189,7 @@ private void checkNonPrimaryKeyFilters(Map<CqlIdentifier, TableFilter> identifie
.toList();

if (!nonPkFilters.isEmpty()) {
throw FilterException.Code.NON_PRIMARY_KEY_FILTER_FOR_UPDATE_DELETE.get(
throw FilterException.Code.UNSUPPORTED_NON_PRIMARY_KEY_FILTER_FOR_UPDATE_DELETE.get(
errVars(
tableSchemaObject,
map -> {
Expand Down Expand Up @@ -229,7 +229,7 @@ private void checkFilteringOnComplexColumns(Map<CqlIdentifier, TableFilter> iden
.toList();

if (!filterOnComplexColumns.isEmpty()) {
throw FilterException.Code.FILTERING_NOT_SUPPORTED_FOR_TYPE.get(
throw FilterException.Code.UNSUPPORTED_FILTERING_FOR_COLUMN_TYPES.get(
errVars(
tableSchemaObject,
map -> {
Expand All @@ -255,7 +255,7 @@ private void checkNoInFilterUsage(Map<CqlIdentifier, TableFilter> identifierToFi
.toList();

if (!inFilterColumns.isEmpty()) {
throw FilterException.Code.INVALID_IN_FILTER_FOR_UPDATE_ONE_DELETE_ONE.get(
throw FilterException.Code.UNSUPPORTED_IN_FILTER_FOR_UPDATE_ONE_DELETE_ONE.get(
errVars(
tableSchemaObject,
map -> {
Expand All @@ -282,7 +282,7 @@ private void checkFullPrimaryKey(Map<CqlIdentifier, TableFilter> identifierToFil
.toList();

if (!missingPKColumns.isEmpty()) {
throw FilterException.Code.FULL_PRIMARY_KEY_REQUIRED_FOR_UPDATE_DELETE.get(
throw FilterException.Code.MISSING_FULL_PRIMARY_KEY_FOR_UPDATE_DELETE.get(
errVars(
tableSchemaObject,
map -> {
Expand All @@ -303,7 +303,7 @@ private void checkValidPrimaryKey(Map<CqlIdentifier, TableFilter> identifierToFi
var outOfOrderClusteringKeys = outOfOrderClusteringKeys(identifierToFilter);

if (!missingPartitionKeys.isEmpty() || !outOfOrderClusteringKeys.isEmpty()) {
throw FilterException.Code.INCOMPLETE_PRIMARY_KEY_FILTER.get(
throw FilterException.Code.INVALID_PRIMARY_KEY_FILTER.get(
errVars(
tableSchemaObject,
map -> {
Expand Down Expand Up @@ -339,7 +339,7 @@ private void checkComparisonFilterAgainstDuration(
.toList();

if (!filteredDurationColumns.isEmpty()) {
throw FilterException.Code.COMPARISON_FILTER_AGAINST_DURATION.get(
throw FilterException.Code.UNSUPPORTED_COMPARISON_FILTER_AGAINST_DURATION.get(
errVars(
tableSchemaObject,
map -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private List<AlterTableAttempt> handleAddColumns(
.collect(Collectors.toList());

if (!duplicateColumns.isEmpty()) {
throw SchemaException.Code.COLUMN_ALREADY_EXISTS.get(
throw SchemaException.Code.CANNOT_ADD_EXISTING_COLUMNS.get(
errVars(
tableSchemaObject,
map -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Operation resolveTableCommand(

// 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(
throw SortException.Code.UNSUPPORTED_SORT_FOR_TABLE_DELETE_COMMAND.get(
errVars(ctx.schemaObject(), map -> {}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public Operation resolveTableCommand(

// 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(
throw SortException.Code.UNSUPPORTED_SORT_FOR_TABLE_UPDATE_COMMAND.get(
errVars(ctx.schemaObject(), map -> {}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private WithWarnings<OrderByCqlClause> resolveVectorSort(
if (skip.isPresent()) {
throw SortException.Code.CANNOT_VECTOR_SORT_WITH_SKIP_OPTION.get();
}
throw SortException.Code.MORE_THAN_ONE_VECTOR_SORT.get(
throw SortException.Code.CANNOT_SORT_ON_MULTIPLE_VECTORS.get(
errVars(
commandContext.schemaObject(),
map -> {
Expand All @@ -194,7 +194,7 @@ private WithWarnings<OrderByCqlClause> resolveVectorSort(
// we have one vector sort - cannot have any other sorting
var nonVectorSorts = sortClause.nonTableVectorSorts();
if (!nonVectorSorts.isEmpty()) {
throw SortException.Code.CANNOT_MIX_VECTOR_AND_NON_VECTOR_SORT.get(
throw SortException.Code.CANNOT_SORT_VECTOR_AND_NON_VECTOR_COLUMNS.get(
errVars(
commandContext.schemaObject(),
map -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void checkUpdateOnPrimaryKey(List<ColumnAssignment> columnAssignments) {
.toList();

if (!invalidUpdatePKColumns.isEmpty()) {
throw UpdateException.Code.UPDATE_PRIMARY_KEY_COLUMNS.get(
throw UpdateException.Code.UNSUPPORTED_UPDATE_FOR_PRIMARY_KEY_COLUMNS.get(
errVars(
tableSchemaObject,
map -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public WithWarnings<UpdateValuesCQLClause> resolve(
var updateClause = command.updateClause();

if (updateClause == null || updateClause.updateOperationDefs().isEmpty()) {
throw UpdateException.Code.ZERO_UPDATE_OPERATIONS_FOR_TABLE.get(
throw UpdateException.Code.MISSING_UPDATE_OPERATIONS.get(
errVars(
commandContext.schemaObject(),
map -> {
Expand All @@ -88,7 +88,7 @@ public WithWarnings<UpdateValuesCQLClause> resolve(

// Collect all used unsupported operator and throw Update exception
if (!usedUnsupportedOperators.isEmpty()) {
throw UpdateException.Code.UNSUPPORTED_UPDATE_OPERATION_FOR_TABLE.get(
throw UpdateException.Code.UNSUPPORTED_UPDATE_OPERATIONS_FOR_TABLE.get(
errVars(
commandContext.schemaObject(),
map -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ApiRegularIndex create(
// regular indexes can only be on primitive. Adding indexes on maps, sets, lists will come
// later.
if (!apiColumnDef.type().isPrimitive()) {
throw SchemaException.Code.DATA_TYPE_NOT_SUPPORTED_BY_INDEXING.get(
throw SchemaException.Code.UNSUPPORTED_INDEXING_FOR_DATA_TYPES.get(
errVars(
tableSchemaObject,
map -> {
Expand All @@ -137,7 +137,7 @@ public ApiRegularIndex create(
|| Options.NORMALIZE.isPresent(optionsDesc.normalize());

if (anyPresent) {
throw SchemaException.Code.TEXT_ANALYSIS_NOT_SUPPORTED_BY_DATA_TYPE.get(
throw SchemaException.Code.UNSUPPORTED_TEXT_ANALYSIS_FOR_DATA_TYPES.get(
errVars(
tableSchemaObject,
map -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public ApiTableDef create(
// TODO: not sure about the validation happening here, was part of the code I moved
// should be in the builder for the attempt
if (partitionIdentifiers.isEmpty()) {
throw SchemaException.Code.ZERO_PARTITION_COLUMNS.get(
throw SchemaException.Code.MISSING_PARTITION_COLUMNS.get(
Map.of("tableColumns", errFmtCqlIdentifier(allColumnDefs.keySet())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io.stargate.sgv2.jsonapi.service.cqldriver.executor.TableSchemaObject;
import io.stargate.sgv2.jsonapi.service.schema.EmbeddingSourceModel;
import io.stargate.sgv2.jsonapi.service.schema.SimilarityFunction;
import io.stargate.sgv2.jsonapi.util.defaults.*;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -193,7 +192,7 @@ public ApiVectorIndex create(

// Vector indexes can only be on vector columns
if (apiColumnDef.type().typeName() != ApiTypeName.VECTOR) {
throw SchemaException.Code.VECTOR_INDEX_NOT_SUPPORTED_BY_DATA_TYPE.get(
throw SchemaException.Code.UNSUPPORTED_VECTOR_INDEX_FOR_DATA_TYPES.get(
errVars(
tableSchemaObject,
map -> {
Expand Down
Loading