Skip to content

Add the summarize operator - #54

Open
davidanthoff wants to merge 1 commit into
mainfrom
add-summarize-operator
Open

Add the summarize operator#54
davidanthoff wants to merge 1 commit into
mainfrom
add-summarize-operator

Conversation

@davidanthoff

Copy link
Copy Markdown
Member

Adds QueryOperators.summarize(source::Enumerable, f, f_expr) — the operator layer for the new @summarize macro in queryverse/Query.jl#356, moved here so it lives alongside the other enumerables and so the generic function is open for backend methods (QueryOperators.summarize(::Queryable, ...) can be overloaded by plan-capturing backends later).

What it does

  • Grouped input (eltype(source) <: Grouping): lowers to a lazy map over the groups — one output row per group.
  • Ungrouped input: the whole source is treated as a single keyless group via the new lazy one-row EnumerableSummarizeAll, which on first iterate collects the rows into a Grouping keyed by the internal _SummarizeUngroupedKey sentinel, so column access on the group works identically in both paths.
  • _key_namedtuple normalizes grouping keys into result columns: NamedTuple keys splat into one column per field, a scalar key becomes a column named key, and the keyless sentinel contributes no columns. Query.jl's @summarize merges this in front of the aggregate columns.
  • A function summarize end stub sits in operators.jl next to pivot_longer/pivot_wider.

Both paths produce a concrete inferred row eltype (verified with isconcretetype tests), since downstream operators rely on Base._return_type.

Notes

🤖 Generated with Claude Code

Adds QueryOperators.summarize for grouped and whole-table aggregation:
grouped input (eltype <: Grouping) lowers to a lazy map over the groups;
ungrouped input is treated as a single keyless group via the new lazy
one-row EnumerableSummarizeAll. The _key_namedtuple helper normalizes
grouping keys into result columns (NamedTuple keys splat, scalar keys
become a column named key, the internal keyless marker contributes none).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
davidanthoff added a commit to queryverse/Query.jl that referenced this pull request Sep 1, 2026
The @summarize macro now expands to QueryOperators.summarize (added in
queryverse/QueryOperators.jl#54); the EnumerableSummarizeAll type, the
keyless-Grouping sentinel and the key normalization helpers move there.
Requires QueryOperators 1.1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant