Skip to content

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

Open
erichare wants to merge 5 commits into
mainfrom
fix/counter-filter-apisupport-2462
Open

erichare wants to merge 5 commits into
mainfrom
fix/counter-filter-apisupport-2462

Conversation

@erichare

@erichare erichare commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does:

Adds BigDecimal and BigInteger counter codecs so JSON numeric filter values convert to CQL counter values. Adds regression coverage for successful counter filtering, exact numeric conversion, overflow, and non-integral input.

Which issue(s) this PR fixes:
Fixes #2462

Verification:
./mvnw test -Dtest=JSONCodecRegistryTest — 170 tests, 0 failures, 0 errors, 0 skipped; formatting checks passed.

Not rerun: UnsupportedTypeTableIntegrationTest, the full unit suite, or integration suites.

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@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 55.07%
This PR 55.09%
Delta 🟢 +0.01%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 55.09% 🍏
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 73.04%
This PR 73.05%
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 73.05% 🍏
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 74.35%
This PR 74.37%
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 74.37% 🍏
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!

This branch has not been deployed

No deployments
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