-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Include user defined SQL Functions #10638
Comments
An easier alternative is to use Native Queries: Here is documentation on adding native queries: https://hasura.io/docs/3.0/reference/connectors/postgresql/native-operations/native-queries Here are few examples of native query templates that you can use for your UDFs (reference for syntax: https://www.postgresql.org/docs/current/sql-syntax-calling-funcs.html) :
OR
OR
Once you have added a native query to your connector, you can reintrospect and add it as a model:
|
Given that we've outlined the option to use native queries — and that we're tracking this internally with support in the future — I'm going to close this issue, @olmohake. While it's not a priority right now, that could change should demand increase.
|
@olmohake — for public tracking, I'm going to reopen this issue and add it to our roadmap 👍 |
I have a function with the following signature: create function age_groups(
area CHAR(8),
date text,
cuts INTEGER[]
) RETURNS TABLE (
age_group TEXT,
amount INTEGER
) AS $$
... and defined the following native query select * from age_groups({{area}}, {{date}}, {{cuts}}) however introspection is dropping the array and returns {
...
"arguments": {
"cuts":{
"name": "cuts",
"type":{
"scalarType": "int4"
}
}
} and accordingly the model looks like this: kind: Model
version: v1
definition:
name: Agegroups
objectType: Agegroups
arguments:
- name: cuts
type: Int4! should i open a separate issue regarding array inputs? |
@olmohake it seems we only support scalar arguments at the moment. Working on changing that, to support array arguments at least. |
@olmohake just wanted you to know, as a workaround: this issue is only a problem with the function introspection. Do let us know if you require help with that while we work on permanently solving this issue. |
v3-engine / postgres-ndc
Is your proposal related to a problem?
I have a sql function that does complex aggregations for a given territory and date and would like to make it available in the supergraph, but the postgres connector does not support user defined functions .
Describe the solution you'd like
Implement introspection and execution for user defined functions.
Describe alternatives you've considered
Reimplement the aggregation logic in a ts or python connector.
The text was updated successfully, but these errors were encountered: