Repository navigation
fix(#9021): an index on an integral key answers for the exact bound, not the truncated one - #9126
Conversation
…not the truncated one A bound no BYTE/SHORT/INTEGER/LONG key equals (12.5, 1e19, 3e9 on an INTEGER) is mapped onto the key that bounds the same set, inclusive, or matches nothing, in SQL (FetchFromIndexStep), openCypher (NodeIndexRangeScan) and the fluent Select API. The SQL BETWEEN scan no longer converts a numeric bound to an integer value's class. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (6)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| BestPractice | 1 minor |
| ErrorProne | 1 medium |
| CodeStyle | 1 minor |
🟢 Metrics 10 complexity
Metric Results Complexity 10
🟢 Coverage 63.16% diff coverage · -5.79% coverage variation
Metric Results Coverage variation ✅ -5.79% coverage variation Diff coverage ✅ 63.16% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (1b1ae3e) 211782 180120 85.05% Head commit (9c3e515) 244390 (+32608) 193715 (+13595) 79.26% (-5.79%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#9126) 19 12 63.16% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Review of #9126The approach is sound. Mapping an inexact bound onto the nearest key that bounds the same set, always inclusive, is the right model, and it lives in one small class ( Issues worth addressing
Smaller points
Security and performanceNo security concerns: no new inputs are parsed, and bound mapping uses Good call filing #9125 for 🤖 Generated with Claude Code |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9126 +/- ##
============================================
+ Coverage 76.80% 76.82% +0.02%
- Complexity 3913 3914 +1
============================================
Files 2123 2123
Lines 211782 211786 +4
Branches 44906 44909 +3
============================================
+ Hits 162665 162714 +49
+ Misses 31699 31667 -32
+ Partials 17418 17405 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Conflict in FetchFromIndexStep: keep both the #9032 null-IN skip (before the mapping) and the #9021 inexact-bound mapping, and both helper sets. Review (claude): - SelectExecutor: NO_KEY moved below CURSOR_BUILDABLE_OPERATORS so the all-caps comment documents the field it belongs to again - SelectExecutor between: a mapped range that inverts (12.2..12.7 -> [13, 12]) answers empty instead of asking the index to read backwards, as SQL and Cypher already do - FetchFromIndexStep: mapInexactIntegralBound returns NO_MATCH/BOUND_KEPT/ BOUND_MAPPED instead of the caller detecting a mapping by reference; the redundant 'inclusive' alias is gone - IntegralKeyBound.isInexact: primitive fast path for Double/Float below 2^53, no BigDecimal for an exact 12.0d - tests: UNIQUE and UNIQUE_HASH indexes, fluent API on every integral key type plus mapped and inverted BETWEEN, SQL BETWEEN with NaN/infinite bounds, descending two-sided mapped ranges, fast-path bound cases, 160-column lines Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it via #9160) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review response (commits 2046858, 9c3e515): Note: main already carries this PR's original #9021 commit (e54f8cb, brought in by #9160). After merging main, this PR's diff is only the review follow-ups below.
Verification: |
|
Review of the follow-up changes (IntegralKeyBound fast path, FetchFromIndexStep mapping status, SelectExecutor empty-range guard, extra tests) I read the diff and the surrounding code. I did not run the tests in this environment (the sandbox blocked the Maven invocation), so everything below comes from reading. Overall: the change looks correct and the invariant ("index returns exactly what the scan returns") is well covered. No blocking issues. What looks good
Minor suggestions (non-blocking)
Residual
Nothing here blocks merging once CI is green. |
… entry says Fixed in 26.10.1 (PR ArcadeData#9126) (#166) Upstream PR ArcadeData#9126 (merge 0ef1877) makes an index on an integral key answer for the exact bound. The strict xfail for ArcadeData#9021 now asserts the fixed rows (i = 12.5 matches nothing, i >= 12.5 returns 13, i < 12.5 returns 11 and 12) on the indexed and on the unindexed type, and checks that the plan of the indexed query reads the index, so the test cannot pass by comparing a scan with a scan. Since #143 the ArcadeData#9021 entry in known-issues.md carried the Fixed paragraph of ArcadeData#9014 and ArcadeData#9027 (PR ArcadeData#9121). That paragraph moves back to its own entry, and ArcadeData#9021 gets a Fixed paragraph for PR ArcadeData#9126. The rounding workaround is kept for engines before 26.10.1. Checked with the 2026-10-03 wheel: on its engine (b22b5e9) the three new cases fail with the answers the issue reports; with the wheel's engine jars replaced by builds of upstream main 2e09816 and 422a5f6, all 11 tests in the file pass. Claude-Session: https://claude.ai/code/session_01Ubz3m6QXHESerCkehC1qgi Co-authored-by: Claude Opus 5.5 <[email protected]>
Closes #9021
An index whose key is BYTE, SHORT, INTEGER or LONG converted every bound to its key type with
Type.convert, which truncates a fraction (12.5 -> 12) and clamps or wraps a value past the key range (1e19 ->Long.MAX_VALUE, 3e9 on an INTEGER wraps). So the index answered for a different bound than the scan:i = 12.5returned the 12,i >= 12.5returned 12,i < 12.5lost it,l = 1e19returnedLong.MAX_VALUE. The newcom.arcadedb.index.IntegralKeyBoundmaps a bound that no integral key equals onto the key that bounds the same set of keys, always inclusive: the smallest key above it for a lower bound, the largest key below it for an upper bound. An equality on such a bound matches nothing. A bound past the range clamps to MIN/MAX or matches nothing. NaN sorts as the greatest number, the same way the scan orders it. The mapping runs where each engine opens its index cursor, so literals and parameters go through the same code.Coverage
Invariant: for a numeric bound on an integral index key, the index returns exactly the rows the scan returns.
FetchFromIndexStepAND-block seeks (=,<,<=,>,>=, two-sided range, composite prefix + range,IN, list parameter)sqlIndexAgreesWithTheScanForEveryOperatorAndInexactBound,sqlLiteralBoundsAgreeWithTheScan,sqlTwoSidedRangesBetweenAndInAgreeWithTheScan,sqlDescendingOrderOverAnInexactRangeFetchFromIndexStepsingle-condition /BETWEEN/INkey paths (createCursor,processBetweenCondition)sqlLinesOfTheIssueBETWEENscan (BetweenCondition): cast the bound to the value's class, so11 BETWEEN 11.5 AND 12.5was truesqlLinesOfTheIssueNodeIndexRangeScan(the<regression from 179cf8d)cypherLinesOfTheIssue,cypherIndexAgreesWithTheScanForEveryOperatorAndInexactBounddatabase.select()(SelectExecutorgt/ge/lt/le/between)lt 12.5lost 12)fluentSelectIndexAgreesWithTheScanNodeIndexSeek,IndexNestedLoopJoin,MatchEdgeByIndexStep), SQL subquery=/IN=is in the operator matrixDELETE FROM index:... WHERE key BETWEEN(DeleteFromIndexStep)theIndexIsUsedForTheBoundsUnderTestasserts that the indexed type's plan really containsFETCH FROM INDEX, so the agreement checks never end up comparing a scan against a scan.Known gaps: #9125 (direct index delete). #8970 (parameter bound past 2^53 on a DOUBLE key) is a separate issue and this PR does not touch it.
Test plan
Issue9021IntegralIndexInexactBoundTest(10 tests): before the fix 7 failed with the issue's exact outputs. With the fix, 10/10 pass. The fluent and BETWEEN-scan assertions also failed with only those two files reverted.Issue8919FloatRangeBoundTest,Issue8333*(index range selectivity, SQL + Cypher): green*Index*Test,*Between*Test,*Range*Test,Select*Test,Issue8*Test,Issue9*Test,*FetchFrom*Testin engine: 3052 tests. 3 failures, all of which also fail onmainc611828 with this PR's sources reverted:Issue741InOperatorEdgeCompositeIndexTest.inValuesAreOrderedAsTheIndexStoresThemNotAsWritten,Issue8872DecimalLiteralDigitsTest.indexedAndUnindexedDoubleAgreeOnALongLiteral,Issue8872DecimalLiteralDigitsTest.updateDeleteAndInOnIndexedDecimalAndDoublecom/arcadedb/query/opencypher/**/*Test+com/arcadedb/query/sql/executor/**/*Test: 2007 tests, greencom/arcadedb/query/select/**, Cypher Where/Comparison tests, SQL parser and operator tests: 820, only the pre-existing Issue741 failureAdversarial pass
There was no subagent (Task) tool in this run, so the Phase 1.5 independent pass did not run. Self-review in its place:
i > 12.2 AND i < 12.7maps to13 <= i <= 12) are detected and answer empty, so the index is never asked to read a range backwards. Covered in SQL, Cypher and fluent.i < 3e9) used to be dropped byvaluesConvertToIndexKeyTypesbefore any mapping, which returned no rows. The mapping now runs first. Covered.sortSeeksInIndexOrdernow also compares the inclusion flags, so two seeks with the same keys but different inclusion are not collapsed.Residual risk
The direct index-delete statement (#9125). Non-numeric bounds (strings) on integral keys keep their existing #5900/#8888 behavior.
Summary by CodeRabbit
BETWEENconditions.