-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
k/enhancementNew feature or improve an existing featureNew feature or improve an existing featurepublic-roadmapt/native-dbs
Milestone
Description
Is your proposal related to a problem?
I am able to filter tables by computed fields and select computed field columns in queries, but I cannot aggregate (e.g. sum) by computed fields.
Here is a repro Hasura Cloud link: https://cloud.hasura.io/project/de479b35-64a2-4211-838b-cf5a4b49ee1a/details
Here is a short video explaining what I mean: https://www.loom.com/share/df97ba8eb905449c9807e433a77e7aab
this is the PostgreSQL schema:
CREATE TABLE code (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
name text NOT NULL,
negate boolean NOT NULL DEFAULT false
);
CREATE UNIQUE INDEX code_pkey ON code(id uuid_ops);
CREATE TABLE payroll_entry (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
code_id uuid NOT NULL,
source_amount numeric NOT NULL
);
CREATE UNIQUE INDEX payroll_entry_pkey ON payroll_entry(id uuid_ops);
CREATE OR REPLACE FUNCTION public.get_payroll_entry_amount(entry payroll_entry)
RETURNS numeric
LANGUAGE sql
STABLE
AS $function$
select (case when negate then -1 else 1 end) * entry.source_amount from code where entry.code_id = code.id
$function$
;
The practical issue for me is that I have a paginated, filterable table with tens of thousands of rows, and I don't want to have to load it all up into memory to sum up the values when the database can do that just fine
Describe the solution you'd like
expose computed fields in aggregations on tables
Describe alternatives you've considered
Not really anything viable I think.
Metadata
Metadata
Assignees
Labels
k/enhancementNew feature or improve an existing featureNew feature or improve an existing featurepublic-roadmapt/native-dbs