Skip to content

fix(scope): fix query stats aggregation bugs found during live SPL demo - #25

Merged
rylero merged 1 commit into
mainfrom
fix/scope-query-agg-bugs
Jul 6, 2026
Merged

rylero merged 1 commit into
mainfrom
fix/scope-query-agg-bugs

Conversation

@rylero

@rylero rylero commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Two real bugs found while running SPL query demos against real match logs:

  1. stats/timechart aggregating Timestamp panics (fixes stats min/max(Timestamp) by <group> crashes daemon connection (EOF) #24). evalAggs did a raw EventTable.Columns["Timestamp"] lookup, but "Timestamp" is a pseudo-column only present via the separate EventTable.Timestamps slice (Pipeline.Run pre-seeds it as already "produced" so it's never fetched into Columns). Indexing the resulting nil slice panicked, killing the daemon connection with a raw EOF on the client (the daemon process itself survived). Fixed by special-casing Timestamp in evalAggs to read from Timestamps directly, same as RowAt already does.

  2. ToFloat64 doesn't coerce numeric strings, so aggregating a lookup-joined CSV column (CSV values are always strings — encoding/csv has no type inference) silently returned 0 instead of the real value or a clear error. avg(Budget)/max(Budget) etc. on a numeric-looking lookup column just silently produced 0. Fixed by having ToFloat64 fall back to strconv.ParseFloat for strings, matching how Splunk treats extracted string fields in eval/stats.

Test plan

  • Regression test TestStatsMinMaxTimestampByGroup (query/query_test.go) — reproduces the exact issue stats min/max(Timestamp) by <group> crashes daemon connection (EOF) #24 repro shape (transaction ... | stats min(Timestamp) as t0, max(Timestamp) as t1 ... by transactionID), verified to panic pre-fix / pass post-fix.
  • Regression test TestStatsAggregatesLookupNumericString (query/query_test.go) — lookup-joins a numeric CSV column and asserts avg/max return real values.
  • go build ./..., go vet ./... clean
  • gofmt -l . — unchanged from pre-existing baseline (24 files, all pre-existing CRLF checkout artifacts unrelated to this diff)
  • go test ./... -race all green

Closes #24.

- evalAggs panicked (nil-slice index out of range) aggregating the
  "Timestamp" pseudo-column, e.g. `stats min(Timestamp)/max(Timestamp)`,
  because Timestamp only exists in EventTable.Timestamps, never in
  Columns. Daemon requests died with a raw EOF client-side. Fixes #24.

- ToFloat64 rejected numeric strings, so aggregating a lookup-joined
  CSV column (always string-typed) silently returned 0 instead of the
  real value or an error. ToFloat64 now coerces numeric strings.

Regression tests added for both.
@rylero
rylero merged commit db721eb into main Jul 6, 2026
1 check passed
@rylero
rylero deleted the fix/scope-query-agg-bugs branch July 6, 2026 06:21
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.

stats min/max(Timestamp) by <group> crashes daemon connection (EOF)

1 participant