Skip to content

Query aggregators#45

Merged
danielrothmann merged 3 commits into
mainfrom
feature/query_aggregators
Feb 6, 2026
Merged

Query aggregators#45
danielrothmann merged 3 commits into
mainfrom
feature/query_aggregators

Conversation

@danielrothmann
Copy link
Copy Markdown
Member

This PR adds support for aggregation clauses to queries, allowing you to compute summary values from an entity result set.

Previously, queries always returned a bag of entities. To get high-level insights (e.g. count of open tasks, total invoice amount), you'd need to export and process the data externally.

Aggregations go at the end of a query as a final clause. They transform the entity set into a single value or extracted fields. The implementation adds an Aggregation enum to the query data model, a new AggregationResult return type, per-aggregation execution modules, and grammar/parser support for parsing them.

Supported aggregations:

  • select <field>, ... — extract specific field values
  • count [<field>] — count entities (optionally by field presence)
  • sum <field> — sum a numeric field (integer, float, or currency)
  • average <field> — compute the mean
  • median <field> — compute the median

Syntax:

from task | where is_completed == false | count
from invoice | where status == "sent" | sum amount
from task | select @id, name, due_date

Closes #37

@danielrothmann danielrothmann merged commit 24d880f into main Feb 6, 2026
1 check passed
@danielrothmann danielrothmann deleted the feature/query_aggregators branch February 6, 2026 14:37
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.

Query aggregators

1 participant