Skip to content

Add support for aggregate functions #589

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

Merged
merged 54 commits into from
May 8, 2025
Merged

Conversation

spitfire55
Copy link
Contributor

What kind of change does this PR introduce?

Add support for aggregates (min, max, avg, count, sum)

What is the current behavior?

No support

What is the new behavior?

Standard support. I'm sure there are edge cases I haven't tested or covered, but this is a good first shot at it.

Additional context

N/A

@olirice olirice requested a review from imor May 5, 2025 18:49
imor added 4 commits May 6, 2025 14:12
Fix whitespace errors reported by pre-commit hook
Fix whitespace errors reported by pre-commit hook
Fix whitespace errors reported by pre-commit hook
Information regarding the aggregate being available for only certain types is already there in the beginning of the aggregates section.
Copy link
Contributor

@imor imor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @spitfire55, thank you for this PR.

I've pushed some minor fixes and added some review comments but not fully done reviewing yet.

spitfire55 added 4 commits May 6, 2025 10:06
- Fix AggregateSelection typename to use field instead of sub_field
- Create helper function for integer type matching
- Refactoring & simplification
- Remove defensive UUID check
- Better log & error strings
@spitfire55 spitfire55 requested a review from imor May 6, 2025 15:24
@imor
Copy link
Contributor

imor commented May 7, 2025

@olirice LGTM. Would like to take a quick look. One question I had was if we'd like to hide the aggregates behind a directive similar to total count for performance reasons.

@olirice
Copy link
Contributor

olirice commented May 7, 2025

nice work on the pr @spitfire55

Yes I think we should have it setup like totalCount as enabled via a comment directive. Otherwise users who upgrade may be surprised to find the surface area of their API grew in a way that could enable inefficient queries

@spitfire55
Copy link
Contributor Author

spitfire55 commented May 7, 2025

Added the comment directive to guard aggregate usage, similar to totalCount. Docs updated as well.

@imor imor merged commit 0aa8dfd into supabase:master May 8, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants