internal/cmd/query: unify JSON output for aggregated and non-aggregated results#343
Merged
Conversation
…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.
1d8e4fd to
939796f
Compare
islameldigwi
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Remove the special-cased aggregation branch from the
-f=jsoncode path. All query results now usetableRowAtIndex()to produce NDJSON objects, regardless of whether the result has aggregation metadata.Problem
When the server returns aggregation metadata on result fields,
tableHasAggregation()returnstrueand routes to a code path that:summarize ... | project a, b, c): silently outputs only the first field's bare scalar value, discarding all other fieldssummarize 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 usestableRowAtIndex().Table output format (
-f=table/ default) is unaffected.Breaking change
Single-field aggregations like
summarize count()now output{"count_":42}instead of bare42. This is deliberate for consistency; the bare scalar behavior was undocumented and surprising.