Repository navigation
Conversation
check_count_from() treated an explicitly stored JSON null as zero
values, so a values_count condition like {"gte": 1} excluded points
whose payload contains the field with a null value. The documented
contract says a stored non-array value counts as 1, and an explicit
null is a stored value -- it is distinct from an absent field, which
is the case check_empty() already handles (and which stays at 0).
Fixes qdrant#10113
📝 WalkthroughWalkthrough
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/segment/src/types.rs`:
- Around line 3395-3399: Update the comment above the Value::Array match arm to
state that absent fields are handled by check_empty, while explicitly stored
empty arrays also produce a count of 0; retain the existing explanation that
explicit null counts as 1.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: c67c1abb-f2e5-4e30-88ab-f6263cf59bfc
📒 Files selected for processing (2)
lib/segment/src/payload_storage/query_checker.rslib/segment/src/types.rs
| // An explicit `null` is a stored non-array value, so it counts as 1 | ||
| // per the documented contract ("if stored value is not an array, the | ||
| // amount of values is assumed to be 1"). Only an *absent* field has | ||
| // a count of 0, which is handled by `check_empty`, not here. | ||
| Value::Array(array) => array.len(), |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the comment about zero counts.
Value::Array(array) => array.len() returns 0 for an explicitly stored empty array. Therefore, “Only an absent field has a count of 0” is incorrect. State that absent fields are handled by check_empty, while empty arrays also produce zero.
Proposed wording fix
- // amount of values is assumed to be 1"). Only an *absent* field has
- // a count of 0, which is handled by `check_empty`, not here.
+ // amount of values is assumed to be 1"). Absent fields are handled
+ // by `check_empty`; an empty array also has a count of 0.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // An explicit `null` is a stored non-array value, so it counts as 1 | |
| // per the documented contract ("if stored value is not an array, the | |
| // amount of values is assumed to be 1"). Only an *absent* field has | |
| // a count of 0, which is handled by `check_empty`, not here. | |
| Value::Array(array) => array.len(), | |
| // An explicit `null` is a stored non-array value, so it counts as 1 | |
| // per the documented contract ("if stored value is not an array, the | |
| // amount of values is assumed to be 1"). Absent fields are handled | |
| // by `check_empty`; an empty array also has a count of 0. | |
| Value::Array(array) => array.len(), |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lib/segment/src/types.rs` around lines 3395 - 3399, Update the comment above
the Value::Array match arm to state that absent fields are handled by
check_empty, while explicitly stored empty arrays also produce a count of 0;
retain the existing explanation that explicit null counts as 1.
|
Thanks for the report. We won't be changing this: #10113, which this PR fixes, was closed as not planned — an explicit |
check_count_from() treated an explicitly stored JSON null as zero values, so a values_count condition like {"gte": 1} excluded points whose payload contains the field with a null value. The documented contract says a stored non-array value counts as 1, and an explicit null is a stored value -- it is distinct from an absent field, which is the case check_empty() already handles (and which stays at 0).
Fixes #10113
All Submissions:
devbranch (notmaster) and my branch was created fromdev.New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --workspace --all-featurescommand?Changes to Core Features: