hasura / hasura/graphql-engine

citus: support relationships in a function's response

Open
#7,186 1 comment 3 reactions 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

Similar to https://github.com/hasura/graphql-engine/issues/7185.

```sql
create function search_disasters(search text)
returns setof disaster as $$
begin
return query select *
from disaster
where
name ilike ('%' || search || '%');
end;
$$ language plpgsql stable;
```

However, trying to use a relationship will result in an error:

```graphql
query function {
search_disasters(args: {search: "sarga"}) {
name
affected_states {
state_id
}
}
}
```

```yaml
message: "cannot pushdown the subquery",
status_code: "0A000",
description: "Complex subqueries and CTEs cannot be in the outer part of the outer join"
```

We'll need to use the primary key columns of the table that the function returns and change the LHS to
```sql
select * from table_the_function_returns where pkey_columns in (select pkey_columns from function(args))
```
from
```sql
select * from function(args)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.