-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented filter by nested collection (#573)
### What Implementing an upcoming feature in ndc-spec: hasura/ndc-spec#166 We want to support filtering by a field inside an array column. For example: I want to get all institutions that where there exists a person who's last name is "Hughes" among their staff. This requires an update to ndc-spec and ndc-sdk-rs. ### How When we get a request with an exists over a nested field collection, we construct a nested field selection expression, unnest the results, and use that as our new "current table".
- Loading branch information
Gil Mizrahi
authored
Aug 20, 2024
1 parent
edce403
commit d787304
Showing
15 changed files
with
407 additions
and
54 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
53 changes: 53 additions & 0 deletions
53
...tests__postgres__explain_tests__query__filter_institution_by_nested_field_collection.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
source: crates/tests/databases-tests/src/postgres/explain_tests.rs | ||
expression: result.details.query | ||
--- | ||
EXPLAIN | ||
SELECT | ||
coalesce(json_agg(row_to_json("%5_universe")), '[]') AS "universe" | ||
FROM | ||
( | ||
SELECT | ||
* | ||
FROM | ||
( | ||
SELECT | ||
coalesce(json_agg(row_to_json("%6_rows")), '[]') AS "rows" | ||
FROM | ||
( | ||
SELECT | ||
"%0_institution_institution"."id" AS "id", | ||
"%0_institution_institution"."name" AS "name", | ||
"%3_nested_fields_collect"."collected" AS "staff" | ||
FROM | ||
"institution"."institution" AS "%0_institution_institution" | ||
LEFT OUTER JOIN LATERAL ( | ||
SELECT | ||
json_agg(row_to_json("%1_nested_fields")) AS "collected" | ||
FROM | ||
( | ||
SELECT | ||
"%2_institution_institution.staff"."first_name" AS "first_name", | ||
"%2_institution_institution.staff"."last_name" AS "last_name", | ||
"%2_institution_institution.staff"."specialities" AS "specialities" | ||
FROM | ||
( | ||
SELECT | ||
(unnest("%0_institution_institution"."staff")).* | ||
) AS "%2_institution_institution.staff" | ||
) AS "%1_nested_fields" | ||
) AS "%3_nested_fields_collect" ON ('true') | ||
WHERE | ||
EXISTS ( | ||
SELECT | ||
1 | ||
FROM | ||
UNNEST("%0_institution_institution"."staff") AS "%4_institution_institution.staff" | ||
WHERE | ||
( | ||
"%4_institution_institution.staff"."last_name" = cast($1 as "pg_catalog"."text") | ||
) | ||
) | ||
) AS "%6_rows" | ||
) AS "%6_rows" | ||
) AS "%5_universe" |
Oops, something went wrong.