Skip to content

Fix #2462: add api support for filtering counter columns#2513

Open
erichare wants to merge 1 commit into
mainfrom
fix/counter-filter-apisupport-2462
Open

Fix #2462: add api support for filtering counter columns#2513
erichare wants to merge 1 commit into
mainfrom
fix/counter-filter-apisupport-2462

Conversation

@erichare

@erichare erichare commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2462.

A table with a counter column was described by the Data API with apiSupport.filter: true, yet filtering on that column failed at runtime with INVALID_FILTER_COLUMN_VALUES. Investigation reveals counters are filterable in CQL via ALLOW FILTERING.

Root cause

Filter literals arrive from JSON as BigDecimal/BigInteger, but COUNTER only registered a single codec, COUNTER_FROM_LONG. Codec lookup therefore found no codec that handlesJavaValue(BigDecimal), threw ToCQLCodecException, and surfaced as INVALID_FILTER_COLUMN_VALUES.

Fix

  • Add COUNTER_FROM_BIG_DECIMAL and COUNTER_FROM_BIG_INTEGER (mirroring BIGINT's variabts ub JSONCodecs, and register them in JSONCodecRegistries.
  • Keep ApiDataTypeDefs.COUNTER apiSupport.filter = true

Tests

  • JSONCodecRegistryTest: added COUNTER cases covering Long / BigInteger / BigDecimal
  • filterCounter rewritten 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 single MISSING_INDEX warning.

Test plan

  • ./mvnw test -Dtest=JSONCodecRegistryTest passes (JDK 21), formatting compliant
  • ./mvnw verify -Dit.test='UnsupportedTypeTableIntegrationTest$Counter' passes against DSE 6.9.21 (all 5 Counter ITs green)
  • CI: full UnsupportedTypeTableIntegrationTest against DSE/HCD matrix

@erichare erichare requested a review from a team as a code owner June 17, 2026 17:25
@erichare erichare requested review from amorton and sl-at-ibm June 17, 2026 17:27
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

📈 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 52.97%
This PR 52.99%
Delta 🟢 +0.02%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 52.99% 🍏
Files changed 100% 🍏

File Coverage
JSONCodecRegistries.java 100% 🍏
JSONCodecs.java 99.45% 🍏

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

📈 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 71.43%
This PR 71.45%
Delta 🟢 +0.02%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (dse69-it)

Overall Project 71.45% 🍏
Files changed 100% 🍏

File Coverage
JSONCodecRegistries.java 100% 🍏
JSONCodecs.java 97.45% 🍏

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

📈 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 72.75%
This PR 72.77%
Delta 🟢 +0.02%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (hcd-it)

Overall Project 72.77% 🍏
Files changed 100% 🍏

File Coverage
JSONCodecRegistries.java 100% 🍏
JSONCodecs.java 97.45% 🍏

@amorton amorton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

-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

@erichare erichare removed the request for review from sl-at-ibm June 18, 2026 02:29
@amorton

amorton commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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

@erichare

Copy link
Copy Markdown
Contributor Author

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)

@erichare erichare changed the title Fix #2462: counter column apiSupport reports filter:false Fix #2462: add api support for filtering counter columns Jun 22, 2026
@erichare erichare force-pushed the fix/counter-filter-apisupport-2462 branch from db7843d to f06232c Compare June 22, 2026 14:50
@erichare erichare requested a review from amorton June 22, 2026 14:55
@erichare erichare force-pushed the fix/counter-filter-apisupport-2462 branch from f06232c to 3603a16 Compare June 22, 2026 14:57
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.
@erichare erichare force-pushed the fix/counter-filter-apisupport-2462 branch from 3603a16 to fbeb50c Compare June 22, 2026 15:01
@erichare

Copy link
Copy Markdown
Contributor Author

@amorton Updated the PR based on our investigation last week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Counter table support lists filter: true, contrary to actual support

2 participants