Skip to content
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

Support expressions in the arg of @aggregate #5242

Merged
merged 8 commits into from
Mar 1, 2024
Merged

Conversation

lutter
Copy link
Collaborator

@lutter lutter commented Feb 26, 2024

It is now possible to use a restricted subset of SQL expressions in the arg of @aggregate annotations. Some examples of what's possible now:

  • @aggregate(fn: "sum", arg: "price * amount")
  • @aggregate(fn: "max", arg: "greatest(amount0, amount1)")
  • even conditional aggregations like @aggregate(fn: "sum", arg: "case when amount0 > amount1 then amount0 else 0 end")

This will help reduce the values that a timeseries needs to store; without this addition, all of the above would have required that mappings calculate these expressions and store them in a separate field in the timeseries.

@lutter lutter force-pushed the lutter/agg-expr branch 2 times, most recently from 08b5c23 to b2b3d28 Compare February 26, 2024 19:24
@fordN fordN requested a review from incrypto32 February 27, 2024 16:40
graph/src/schema/input/sqlexpr.rs Outdated Show resolved Hide resolved
graph/src/schema/input/sqlexpr.rs Show resolved Hide resolved
graph/src/schema/input/sqlexpr.rs Outdated Show resolved Hide resolved
@incrypto32
Copy link
Member

LGTM

@lutter lutter force-pushed the lutter/agg-expr branch from 23d57b0 to 2fb9636 Compare March 1, 2024 18:02
@lutter lutter force-pushed the lutter/agg-expr branch from 2fb9636 to a15b903 Compare March 1, 2024 19:41
@lutter lutter merged commit a15b903 into master Mar 1, 2024
7 checks passed
@lutter lutter deleted the lutter/agg-expr branch March 1, 2024 19:41
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.

2 participants