-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/match arrays lightning query #5047
Conversation
WalkthroughThe changes introduce a new function, Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
efa9413
to
9e00d00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
fiftyone/server/lightning.py (1)
417-434
: Add documentation and improve type hints.While the implementation is correct, consider these improvements for better maintainability:
-def _match_arrays(dataset: fo.Dataset, path: str, is_frame_field: bool): +def _match_arrays( + dataset: fo.Dataset, + path: str, + is_frame_field: bool, +) -> t.List[t.Dict[str, t.Any]]: + """Build MongoDB pipeline stages for matching documents with array fields. + + Args: + dataset: The FiftyOne dataset + path: The field path to match + is_frame_field: Whether this is a frame-level field + + Returns: + A list of pipeline stages that match documents containing arrays + """ keys = path.split(".") path = None pipeline = []
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
fiftyone/server/lightning.py
(2 hunks)
🔇 Additional comments (1)
fiftyone/server/lightning.py (1)
366-369
: LGTM! Verify array matching behavior.
The integration of _match_arrays
into the pipeline looks correct and should fix the null responses for min/max queries on array fields.
Let's verify the fix works for nested arrays:
✅ Verification successful
Array matching implementation is consistent with codebase patterns
The verification shows that:
- The
$unwind
operation is consistently used across the codebase for array handling - The new
_match_arrays
implementation follows similar patterns seen in other MongoDB pipeline builders - Array field handling is properly integrated with frame fields through
is_frame_field
checks - The implementation aligns with existing array operations in core modules like
collections.py
,view.py
, andaggregations.py
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for similar array matching patterns in the codebase
# to ensure consistent handling across different query types
# Look for other MongoDB pipeline builders that might need similar array matching
rg -l 'append.*\$match.*\$exists' --type py
# Look for test files that verify array queries
rg -l 'test.*array.*query' --type py
Length of output: 113
Script:
#!/bin/bash
# Let's look for array-related test cases and MongoDB pipeline patterns more broadly
# Search for array-related test cases with different patterns
rg -l "test.*array" tests/
rg -l "array.*test" tests/
# Look for MongoDB pipeline patterns with array operations
rg -A 5 '\$unwind|\$match.*array' --type py
# Check the implementation of _match_arrays function
rg -A 10 '_match_arrays' fiftyone/server/lightning.py
# Look for similar array handling patterns
rg -A 5 'is_frame_field.*pipeline' --type py
Length of output: 10222
What changes are proposed in this pull request?
Fixes
null
responses for min / max lightning queriesWhat areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit
New Features
Bug Fixes