Skip to content

internal/cmd/query: unify JSON output for aggregated and non-aggregated results#343

Merged
lukasmalkmus merged 1 commit into
mainfrom
lukasmalkmus/ypsqxnrsumns
Mar 26, 2026
Merged

internal/cmd/query: unify JSON output for aggregated and non-aggregated results#343
lukasmalkmus merged 1 commit into
mainfrom
lukasmalkmus/ypsqxnrsumns

Conversation

@lukasmalkmus

@lukasmalkmus lukasmalkmus commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator

Overview

Remove the special-cased aggregation branch from the -f=json code path. All query results now use tableRowAtIndex() to produce NDJSON objects, regardless of whether the result has aggregation metadata.

Problem

When the server returns aggregation metadata on result fields, tableHasAggregation() returns true and routes to a code path that:

  • Multi-field results (e.g., summarize ... | project a, b, c): silently outputs only the first field's bare scalar value, discarding all other fields
  • Grouped aggregations (e.g., summarize count() by status): errors with "JSON output format is not supported for aggregated results with groups"

Fix

Delete the tableHasAggregation() branch from the JSON code path and let all results flow through the existing NDJSON loop that uses tableRowAtIndex().

Table output format (-f=table / default) is unaffected.

Breaking change

Single-field aggregations like summarize count() now output {"count_":42} instead of bare 42. This is deliberate for consistency; the bare scalar behavior was undocumented and surprising.

@lukasmalkmus lukasmalkmus self-assigned this Mar 26, 2026
@lukasmalkmus lukasmalkmus marked this pull request as ready for review March 26, 2026 11:49
…ed results

Remove the special-cased aggregation branch from the -f=json code path.
All query results now use tableRowAtIndex() to produce NDJSON objects,
regardless of whether the result has aggregation metadata.

Previously, aggregated results without groups output only the first
field's bare scalar value (table.Columns[0][0]), silently discarding
other fields. Aggregated results with groups errored entirely.

A server-side optimizer change (axiomhq/axiom#16816) now preserves
aggregation metadata on fields that were previously stripped, causing
multi-field queries (e.g. summarize ... | project a, b, c) to hit the
broken scalar path.

The fix deletes the aggregation branch and lets all results flow through
the existing, correct NDJSON loop. Table output format is unaffected.
@lukasmalkmus lukasmalkmus force-pushed the lukasmalkmus/ypsqxnrsumns branch from 1d8e4fd to 939796f Compare March 26, 2026 13:11
@lukasmalkmus lukasmalkmus enabled auto-merge (rebase) March 26, 2026 13:15
@lukasmalkmus lukasmalkmus merged commit d74d810 into main Mar 26, 2026
8 checks passed
@lukasmalkmus lukasmalkmus deleted the lukasmalkmus/ypsqxnrsumns branch March 26, 2026 13:16
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