Skip to content

feat(scope): add --format csv to query/query-multi - #26

Merged
rylero merged 4 commits into
mainfrom
worktree-cached-spinning-raccoon
Jul 6, 2026
Merged

rylero merged 4 commits into
mainfrom
worktree-cached-spinning-raccoon

Conversation

@rylero

@rylero rylero commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add --format csv to query and query-multi (union mode) so results can go straight into pandas.read_csv() instead of round-tripping through JSON.
  • CSV header is the union of all row keys across the result set, sorted alphabetically with Timestamp pinned first, so heterogeneous rows (e.g. stats/timechart ... by group) still produce a stable, complete header.
  • query-multi --format csv requires --union true; comparison mode's per-session shape isn't row-shaped and errors out with a clear message instead.
  • Updated the help command's schema/notes to document the new flag.

Test plan

  • go build ./...
  • go test ./...
  • New tests: CSV output for query, heterogeneous-column CSV padding, unsupported --format error, query-multi --format csv without --union true error

🤖 Generated with Claude Code

rylero and others added 2 commits July 6, 2026 00:03
CSV output lets query results feed pandas.read_csv() directly
without a JSON parsing round-trip. Columns are the union of all
row keys, sorted alphabetically with Timestamp pinned first for
determinism across heterogeneous rows (e.g. stats/timechart by
group). query-multi requires --union true since comparison mode
isn't row-shaped.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Parquet preserves native bool/float64/string types and true nulls
for missing columns, unlike CSV which must stringify everything.
Column type per field is inferred from non-nil values (bool/float64/
string), falling back to a stringified UTF8 column on any mix so
the writer never errors on unexpected value shapes.

Also fix CSV output to write bools as "True"/"False" instead of
Go's lowercase "true"/"false" -- pandas.read_csv's C parser only
recognizes the capitalized form as boolean, otherwise the column
comes back as object dtype.

Adds github.com/parquet-go/parquet-go as a new dependency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rylero
rylero force-pushed the worktree-cached-spinning-raccoon branch from 444decf to 78d1db8 Compare July 6, 2026 07:07
rylero and others added 2 commits July 6, 2026 00:09
…python client

SKILL.md hadn't been updated for #27 (claudescope-py) or #28
(--follow/search-fields), and this branch adds --format csv/parquet
on top -- the agent-facing guide was missing all four. Documents:
- search-fields command
- --format csv/parquet output for query/query-multi --union true
- query --follow true live streaming (NDJSON, incompatible with
  --format/--out)
- the claudescope-py Python client, recommended over --format for
  Python consumers since it builds a DataFrame directly

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Found via end-to-end testing against a real .wpilog and pandas
(not just Go-side round-trip tests): rowsToParquet wrote rows via
GenericWriter's map/reflect path (w.Write([]map[string]any{...})),
whose isNullValue check (parquet-go's column_buffer_reflect.go)
treats any Go zero value -- false, 0.0, "" -- as equivalent to an
absent key for Optional columns. A real Enabled=false or a sensor
reading of exactly 0.0 was silently coming back as a Parquet null
(NaN/None in pandas), which is a correctness bug that would corrupt
real telemetry data on release.

Fix: build parquet.Row values manually with explicit definition
levels (1 = present, 0 = null) via schema.Lookup for each column's
index, bypassing the reflect path entirely. Verified against real
pandas: false/0.0/"" now round-trip as themselves, while genuinely
missing columns (e.g. an unmatched lookup join) still round-trip as
null. Added a regression test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rylero
rylero marked this pull request as ready for review July 6, 2026 07:35
@rylero
rylero merged commit da4a270 into main Jul 6, 2026
1 check passed
@rylero
rylero deleted the worktree-cached-spinning-raccoon branch July 6, 2026 07:35
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