diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/schema/tables/ApiDataTypeDefs.java b/src/main/java/io/stargate/sgv2/jsonapi/service/schema/tables/ApiDataTypeDefs.java index b1ff17cdd4..1c1ebf1a0d 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/schema/tables/ApiDataTypeDefs.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/schema/tables/ApiDataTypeDefs.java @@ -74,7 +74,9 @@ public abstract class ApiDataTypeDefs { new PrimitiveApiDataTypeDef( ApiTypeName.COUNTER, DataTypes.COUNTER, - new ApiSupportDef.Support(false, false, true, true, ApiSupportDef.Update.NONE), + // counter values cannot be used in a filter (no CQL codec to bind them), so filter is + // false to match actual support, see #2462 + new ApiSupportDef.Support(false, false, true, false, ApiSupportDef.Update.NONE), // we do not support the user creating anything with a counter type, but we accept if the // DB says new DefaultTypeBindingRules( diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/tables/UnsupportedTypeTableIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/tables/UnsupportedTypeTableIntegrationTest.java index a7ee8a0c9e..27cbbbb0f6 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/tables/UnsupportedTypeTableIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/tables/UnsupportedTypeTableIntegrationTest.java @@ -141,7 +141,7 @@ public void canNotFilterOnFrozen() { /** * Data API support for counter column: CreateTable(False), Insert(false), Read(True), - * Filter(True) + * Filter(False) */ @Nested @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @@ -161,6 +161,25 @@ public final void createDefaultTablesAndIndexes() { assertThat(executeCqlStatement(createTable.build())).isTrue(); } + // Regression test for #2462: a counter column must report apiSupport.filter == false in the + // table description, because filtering on a counter is not actually supported (see + // filterCounter() below). Previously it incorrectly reported filter == true. + @Test + @Order(2) + public final void listTablesReportsCounterNotFilterable() { + var apiSupportPath = + "status.tables.find { it.name == '%s' }.definition.columns.counter.apiSupport" + .formatted(TABLE_COUNTER); + assertNamespaceCommand(keyspaceName) + .templated() + .listTables(true) + .wasSuccessful() + .body(apiSupportPath + ".createTable", is(false)) + .body(apiSupportPath + ".insert", is(false)) + .body(apiSupportPath + ".read", is(true)) + .body(apiSupportPath + ".filter", is(false)); + } + // In Cassandra, you cannot use an INSERT statement directly for counters. // Instead, counter columns require a special kind of update operation. // Counters in Cassandra are designed to increment or decrement a value,