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 cumulative aggregations #5209

Merged
merged 6 commits into from
Feb 22, 2024
Merged

Support cumulative aggregations #5209

merged 6 commits into from
Feb 22, 2024

Conversation

lutter
Copy link
Collaborator

@lutter lutter commented Feb 14, 2024

This PR allows aggregates that are cumulative from the beginning of time rather than just within a time interval. That is indicated by declaring the aggregate as @aggregate(fn: "sum", arg:"amount", cumulative: true)

Check the docs in ./docs/aggregation.md for more details.

Note that this PR is on top of PR #5208

@lutter lutter deleted the branch master February 19, 2024 19:42
@lutter lutter closed this Feb 19, 2024
@lutter lutter reopened this Feb 19, 2024
@lutter lutter changed the base branch from lutter/agg-minmax to master February 19, 2024 20:17
Comment on lines 169 to 259
Ok(IdType::Bytes) => "max(id::text)::bytea",
Ok(IdType::String) | Ok(IdType::Int8) => "max(id)",
Copy link
Member

Choose a reason for hiding this comment

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

Isn't Int8 the only type one allowed for the ID field in a time series?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think that's a leftover from before I made Int8 mandatory as the id

Sum => write!(w, "sum(\"{}\")", self.src_column.unwrap().name)?,
Max => write!(w, "max(\"{}\")", self.src_column.unwrap().name)?,
Min => write!(w, "min(\"{}\")", self.src_column.unwrap().name)?,
Sum => write!(w, "sum(\"{}\")", src.unwrap())?,
Copy link
Member

Choose a reason for hiding this comment

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

would it be cleaner to take a &SqlName instead of Option and call unwrap from the caller?

Copy link
Member

Choose a reason for hiding this comment

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

Ignore this was resolved in a later commit than when reviewed

No actual change in functionality
Instead of having an Option for the argument to accomodate `count` which
has no argument, use `id` as a dummy argument for that case.
For immutable entities, creating a BRIN index on (block$, vid) is not very
helpful. A normal BTree on just block$ works much better.
@lutter lutter merged commit 01be1d1 into master Feb 22, 2024
7 checks passed
@lutter lutter deleted the lutter/agg-lifetime branch February 22, 2024 19:19
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