hasura / hasura/graphql-engine
Aggregating on postgres interval columns
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Discussed in https://github.com/hasura/graphql-engine/discussions/9365
Originally posted by **otonnesen** January 6, 2023
Hi all,
I'm trying to perform an aggregation query on a table with an interval column, but I'm getting an error. I couldn't find any info on interval aggregations in the docs github issues. Am I just missing something obvious in the example below, or can intervals not be used in Hasura's built-in aggregation utilities?
### Context
Running Postgres 14.4 and Hasura 2.16.1.
Table:
```sql
create table test (id bigint, duration interval);
```
Query:
```gql
{
test_aggregate {
aggregate {
sum {
duration
}
}
nodes {
id
}
}
}
```
Error:
```json
{
"errors": [
{
"extensions": {
"code": "validation-failed",
"path": "$.selectionSet.test_aggregate.selectionSet.aggregate.selectionSet.sum.selectionSet.duration"
},
"message": "field 'duration' not found in type: 'test_sum_fields'"
}
]
}
```
Contributor guide
Research direction
Start by reading discussion #9365 and reproducing the shown test_aggregate query on PostgreSQL 14.4 with Hasura 2.16.1. Compare the supported aggregate fields for interval columns; done means either interval aggregation works for the requested sum or the limitation is documented clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgresql
- Domain
- api, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100