Fix #2462: add api support for filtering counter columns#2513
Conversation
📈 Unit Test Coverage Delta vs Main Branch
|
Unit Test Coverage Report
|
📈 Integration Test Coverage Delta vs Main Branch (dse69-it)
|
Integration Test Coverage Report (dse69-it)
|
📈 Integration Test Coverage Delta vs Main Branch (hcd-it)
|
Integration Test Coverage Report (hcd-it)
|
There was a problem hiding this comment.
-1 Blocking this merging.
There are two possible fixes here: either the API support flag is wrong (we dont support it) OR we actually should support it and the bug is that we dont.
we need to decide on what we want to do before letting AI write code. Also, PR comments such as these are not very helpful it is just a mash of words
|
There is an existing test the confirms some code things we should not be able to filter on a counter BUT checking the design docs we said it was possible to filter on a counter. we need to work out what is the correct behaviour |
|
Good point @amorton, digging into this in more detail (i.e., whether there's a technical reason why we don't support it, and if so, can we overcome that and support it, as the spec indicates that we want to do) |
db7843d to
f06232c
Compare
f06232c to
3603a16
Compare
A table with a counter column was described with apiSupport.filter:true, but filtering on a counter actually failed at runtime with INVALID_FILTER_COLUMN_VALUES. The describe output was correct — counters ARE filterable in CQL via ALLOW FILTERING (they just cannot be indexed) — the gap was a missing JSON->CQL codec. Filter literals arrive as BigDecimal/BigInteger, but COUNTER only registered COUNTER_FROM_LONG, so codec lookup threw ToCQLCodecException. Add COUNTER_FROM_BIG_DECIMAL and COUNTER_FROM_BIG_INTEGER (mirroring BIGINT's longValueExact variants) and register them. With the codecs in place, WhereCQLClauseAnalyzer proceeds with ALLOW FILTERING and emits a MISSING_INDEX warning, so apiSupport.filter stays true. This reverses the earlier flip-to-false approach: keep filter=true and make the runtime match it. insert/update remain unsupported (insert=false / Update.NONE), and isUnsupportedDML() is unchanged (already true via insert=false). Tests: - JSONCodecRegistryTest: add COUNTER cases for Long/BigInteger/BigDecimal -> Long binding. - UnsupportedTypeTableIntegrationTest.Counter: assert describe reports filter:true; rewrite filterCounter to seed a counter via raw CQL and expect the row back with a MISSING_INDEX warning.
3603a16 to
fbeb50c
Compare
|
@amorton Updated the PR based on our investigation last week! |
Summary
Fixes #2462.
A table with a
countercolumn was described by the Data API withapiSupport.filter: true, yet filtering on that column failed at runtime withINVALID_FILTER_COLUMN_VALUES. Investigation reveals counters are filterable in CQL viaALLOW FILTERING.Root cause
Filter literals arrive from JSON as
BigDecimal/BigInteger, butCOUNTERonly registered a single codec,COUNTER_FROM_LONG. Codec lookup therefore found no codec thathandlesJavaValue(BigDecimal), threwToCQLCodecException, and surfaced asINVALID_FILTER_COLUMN_VALUES.Fix
COUNTER_FROM_BIG_DECIMALandCOUNTER_FROM_BIG_INTEGER(mirroringBIGINT's variabts ubJSONCodecs, and register them inJSONCodecRegistries.ApiDataTypeDefs.COUNTERapiSupport.filter = trueTests
JSONCodecRegistryTest: addedCOUNTERcases coveringLong/BigInteger/BigDecimalfilterCounterrewritten from error-expecting to success-expecting: seeds a counter value via raw CQL then filters on equality and asserts the row is returned with a singleMISSING_INDEXwarning.Test plan
./mvnw test -Dtest=JSONCodecRegistryTestpasses (JDK 21), formatting compliant./mvnw verify -Dit.test='UnsupportedTypeTableIntegrationTest$Counter'passes against DSE 6.9.21 (all 5 Counter ITs green)UnsupportedTypeTableIntegrationTestagainst DSE/HCD matrix