aggregate
Run server-side GROUP BY aggregations on tabular data, returning summaries instead of raw rows to reduce token usage. Includes count, sum, avg, min, max, count_distinct, median.
Instructions
Server-side aggregations (GROUP BY). Saves orders of magnitude in tokens vs returning rows for the LLM to aggregate. Functions: count, sum, avg, min, max, count_distinct, median. limit capped at 1000.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max groups returned (default 50) | |
| having | No | Post-aggregation filter on aggregation aliases (B11). Each item: {"column": <alias>, "op": eq|neq|gt|gte|lt|lte|in|between|is_null, "value": ...} | |
| redact | No | Scrub PII / credentials from group-by column values (default true). Aggregate values (counts, sums, etc.) are never altered. | |
| dataset | Yes | Dataset identifier | |
| filters | No | Pre-filter rows before aggregating (same syntax as get_rows) | |
| group_by | No | Group-by columns. Empty = whole-dataset aggregate. | |
| order_by | No | Column or alias to sort by | |
| order_dir | No | desc | |
| approximate | No | Approximate-mode aggregation (C1). Routes count_distinct → HyperLogLog (~2% error), median → t-digest (~1% error), sum/avg → sampled estimator with 95% confidence interval. Whole-dataset only. | |
| aggregations | Yes | Aggregation specs. Use column='*' for COUNT(*). | |
| redact_patterns | No | Additional Python regex patterns to layer on top of the built-in set. | |
| redact_skip_columns | No | Group-by column names to exempt from redaction. |