Repository navigation
fix(#6577): OR with a non-cursor-buildable operator (NEQ/LIKE/ILIKE) silently drops rows - #6684
Conversation
isTheNodeFullyIndexed() only excluded is_null/is_not_null from "this leaf is indexed"; every other operator on an indexed property (neq/like/ilike) was treated as indexed even though filterWithIndexesFinalNode()'s cursor-building switch has no case for them and silently falls through to a bare return, contributing zero cursors. Under an OR whose "both sides indexed" gate then passed on that looser check, the neq/like/ilike branch contributed no rows at all while its sibling's cursor became the entire candidate stream - a correctness bug, not a performance one: matching records were silently dropped. Extract the operator set filterWithIndexesFinalNode() can actually build a cursor for (eq/in_op/between/gt/ge/lt/le) into one shared CURSOR_BUILDABLE_OPERATORS field, and have isTheNodeFullyIndexed() key its "is this leaf indexed" check off it instead of the narrower is_null/is_not_null exclusion, so the two can no longer independently drift the way this bug happened in the first place.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthrough
ChangesCursor-buildability fallback
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR corrects index handling for non-cursor-buildable operators and adds regression coverage; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
🟢 Coverage 75.00% diff coverage · -6.48% coverage variation
Metric Results Coverage variation ✅ -6.48% coverage variation Diff coverage ✅ 75.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (e7dc2fc) 165763 132646 80.02% Head commit (0af07c7) 198153 (+32390) 145719 (+13073) 73.54% (-6.48%) 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 (#6684) 4 3 75.00% 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.
|
Tick the box to add this pull request to the merge queue (same as
|
ReviewNicely scoped fix for a real correctness bug (silent row-dropping under Correctness
Test coverage
Style / minor
Overall this looks correct and well-tested. I wasn't able to execute |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6684 +/- ##
==========================================
- Coverage 71.36% 71.35% -0.02%
==========================================
Files 1871 1871
Lines 165763 165766 +3
Branches 35050 35051 +1
==========================================
- Hits 118302 118286 -16
- Misses 33157 33170 +13
- Partials 14304 14310 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #6577
Summary
SelectExecutor.isTheNodeFullyIndexed()(used byfilterWithIndexesFinalNode()'s "under anOR, both sides must be indexed" gate) only excludedis_null/is_not_nullfrom "this leaf is indexed" - every other operator on an indexed property, includingneq/like/ilike, was treated as indexed as long as the property had an index. ButfilterWithIndexesFinalNode()'s cursor-buildingswitchonly knows how to build a cursor foreq/in_op/between/gt/ge/lt/le; aneq/like/ilikeleaf falls through to a barereturnand contributes no cursor at all.So for
a != 'nonexistent' OR n = -1: the "both sides indexed" gate passed (both properties have indexes), theneqleaf silently contributed zero cursors, and theeqleaf's cursor alone became the entire candidate stream - every record matching only theneqbranch was silently dropped from the result. This is a missing-rows correctness bug, not a performance one.The fix extracts the operator set
filterWithIndexesFinalNode()can actually turn into a cursor (eq,in_op,between,gt,ge,lt,le) into one sharedCURSOR_BUILDABLE_OPERATORSfield, and hasisTheNodeFullyIndexed()key its "is this leaf indexed" check off that same set instead of the narroweris_null/is_not_nullexclusion - mirroring the suggested fix in the issue so the two call sites can no longer independently drift apart the way this bug happened in the first place.filterWithIndexesFinalNode()also gets a cheap defensive early-return against the same set, as a mirror of its ownswitchin case the invariant is ever loosened elsewhere.A
neq/like/ilikeleaf under anORnow correctly falls back to a full scan for that branch (whichisTheNodeFullyIndexed()'sorcase already unions with||, so the overall query still uses whatever index it can and only loses the "both sides indexed" fast path) instead of silently losing rows.Test plan
New regression test
Issue6577OrWithNonCursorBuildableOperatorTest(engine/src/test/java/com/arcadedb/query/select/), reproducing the issue's exact scenario plus siblings:orWithNeqOnOneSideMustNotDropTheOtherBranch- the issue's repro (a != 'nonexistent' OR n = -1), asserts all 1000 rows are returned.orWithNeqOnOneSideMustNotDropTheOtherBranchReversed- same shape withneqon the right-hand side of theor.orWithLikeOnOneSideMustNotDropTheOtherBranch/orWithIlikeOnOneSideMustNotDropTheOtherBranch- same defect vialike/ilike.orWithNeqOnBothSidesFallsBackToFullScanCorrectly- both branches non-cursor-buildable, verifying the pre-existing full-scan fallback stays correct.Verified:
main(0Linstead of1000L) before the fix, confirming they reproduce the bug.com.arcadedb.query.selectpackage regression suite (115 tests acrossIssue6565SelectIndexCandidateLimitTest,SelectCompositeIndexTest,SelectExecutionTest,SelectIndexExecutionTest,SelectOperatorsExtendedTest,SelectOrderByTest,SelectParallelIteratorTest,SelectTraversalTest,SelectVectorTest, plus the new test) passes with no regressions.mvn -pl engine -am compilesucceeds cleanly.Summary by CodeRabbit
ORconditions involvingneq,like, andilikeoperators.