Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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.
🧹 Nitpick comments (1)
lib/segment/src/payload_storage/query_checker.rs (1)
494-533: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd one falsy missing-field case.
These assertions only cover matches. A regression that made missing fields satisfy every
values_countfilter would still pass, so please add one negative case likegt: 0orlt: 0.Suggested test addition
let missing_value_count_condition_lte = Filter::new_must(Condition::Field(FieldCondition::new_values_count( JsonPath::new("non_existent_field"), ValuesCount { lt: None, gt: None, gte: None, lte: Some(0), }, ))); assert!(payload_checker.check(0, &missing_value_count_condition_lte)); + + let missing_value_count_condition_gt = + Filter::new_must(Condition::Field(FieldCondition::new_values_count( + JsonPath::new("non_existent_field"), + ValuesCount { + lt: None, + gt: Some(0), + gte: None, + lte: None, + }, + ))); + assert!(!payload_checker.check(0, &missing_value_count_condition_gt));🤖 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/payload_storage/query_checker.rs` around lines 494 - 533, The new missing-field values_count tests in query_checker should include at least one negative assertion, not just matching cases. Add a falsy case in the existing payload_checker check coverage around missing_value_count_condition so a non-existent field with an impossible constraint like gt: 0 or lt: 0 is asserted to fail, using the same FieldCondition::new_values_count and Filter::new_must pattern to keep the test aligned with the current setup.
🤖 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.
Nitpick comments:
In `@lib/segment/src/payload_storage/query_checker.rs`:
- Around line 494-533: The new missing-field values_count tests in query_checker
should include at least one negative assertion, not just matching cases. Add a
falsy case in the existing payload_checker check coverage around
missing_value_count_condition so a non-existent field with an impossible
constraint like gt: 0 or lt: 0 is asserted to fail, using the same
FieldCondition::new_values_count and Filter::new_must pattern to keep the test
aligned with the current setup.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: a01b9dfd-e6cb-4cb7-a245-86f83acfcc0f
📒 Files selected for processing (2)
lib/segment/src/payload_storage/condition_checker.rslib/segment/src/payload_storage/query_checker.rs
|
Requesting a review or a suggestion! |
✅ Action performedReviews resumed. |
|
Hey @onlyarnav, thanks for the contrinution. I think the approach and implementation is correct, but there are some conflicts due to rebase. I will proceed with alrternative PR: |
Summary
Fixes a bug where
values_countfilter queries returned incorrect results when evaluating points that were missing the target payload field.Issue: #9586 & #9065
Problem
Previously, when a query condition evaluated a payload field that did not exist on a point (e.g.
tagson a point with notagsfield), the query engine fell back to callingcheck_empty()on theFieldCondition.In
FieldCondition::check_empty(), thevalues_countcheck was completely ignored (using a wildcard patternvalues_count: _), causing it to default tofalse. This meant conditions likevalues_countwithlt: 1,lte: 0, orgte: 0(which should match a point missing the field since its value count is0) incorrectly returnedfalse.Solution
FieldCondition::check_empty()inlib/segment/src/payload_storage/condition_checker.rsto evaluate thevalues_countcheck (if present) by callingvalues_count.check_empty(). This successfully checks conditions against a count of0.lib/segment/src/payload_storage/query_checker.rsto cover these scenarios:values_countcheck withlt: 1matching a missing field (value count of0).values_countcheck withgte: 0matching a missing field.values_countcheck withlte: 0matching a missing field.[Drafted by Claude Code (Opus 4.8)]