-
Notifications
You must be signed in to change notification settings - Fork 11
Handle Array Exists/Not Exists in Flat Collections #250
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
Merged
suresh-prakash
merged 16 commits into
hypertrace:main
from
suddendust:handle_array_exists_flat_collections
Nov 25, 2025
Merged
Handle Array Exists/Not Exists in Flat Collections #250
suresh-prakash
merged 16 commits into
hypertrace:main
from
suddendust:handle_array_exists_flat_collections
Nov 25, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ype info to flat collections
…y_id_expressions_flat
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #250 +/- ##
============================================
+ Coverage 79.70% 80.02% +0.31%
- Complexity 1209 1249 +40
============================================
Files 226 227 +1
Lines 5701 5756 +55
Branches 492 500 +8
============================================
+ Hits 4544 4606 +62
+ Misses 809 805 -4
+ Partials 348 345 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
suresh-prakash
previously approved these changes
Nov 19, 2025
…le_array_exists_flat_collections
This reverts commit ce28574.
puneet-traceable
previously approved these changes
Nov 24, 2025
puneet-traceable
approved these changes
Nov 25, 2025
suresh-prakash
approved these changes
Nov 25, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
For
entity-servicequeries that check for an array to beIS EMPTYorIS NOT EMPTY(this is what ES receives from GQL):The currently parsed PG query is:
This predicate
"attributes.responseDataTypeIds" IS NOT NULLis semantically incorrect as this returns empty arrays, which is not in sync-with Mongo's behaviour (which only returns arrays with length > 0). We need to align this behaviour.These changes use
JsonIdentifierExpressionto identify array fields in JSON cols, and based on that information, it uses thecardinalityoperator to check the length of an array.Summary
Note: For
JSONBfields, the parser assumes aGINindex on them (so forcustomAttribute->tags, we've aGINindex oncustomAttribute).EXISTSon top-level scalar field"status" IS NOT NULLEXISTSon top-level array field(cardinality("tags") > 0)EXISTSonJSONBscalar field"customAttribute" ? 'brand'EXISTSonJSONBarray field("props" @> '{"colors": []}' AND jsonb_array_length("props"->'colors') > 0)NOT EXISTSon top-level scalar field"status" IS NULLNOT EXISTSon top-level array fieldCOALESCE(cardinality("tags"), 0) = 0NOT EXISTSonJSONBscalar fieldNOT ("customAttribute" ? 'brand')NOT EXISTSonJSONBarray fieldCOALESCE(jsonb_array_length("props"->'colors'), 0) = 0Checklist: