Skip to content

feat: add query and head subcommands for agent data exploration#5

Merged
SpollaL merged 1 commit into
masterfrom
feat/query-head-subcommands
Apr 24, 2026
Merged

feat: add query and head subcommands for agent data exploration#5
SpollaL merged 1 commit into
masterfrom
feat/query-head-subcommands

Conversation

@SpollaL
Copy link
Copy Markdown
Owner

@SpollaL SpollaL commented Apr 24, 2026

Summary

  • New sentinel query <file> --sql "..." subcommand — runs arbitrary SQL against the registered data table and streams rows as JSONL; row cap applied via DataFrame::limit (default --max-rows 1000) so user WITH/UNION/ORDER BY clauses pass through unchanged.
  • New sentinel head <file> [-n N] subcommand — thin wrapper over query, returns first N rows as JSONL (default 10).
  • Factored fetch_violation_samples' per-DataType downcasting (~170 lines) into src/arrow_json.rs, rebuilt on arrow::json::WriterBuilder; --show-violations samples now also cover timestamps, dates, and decimals.
  • Exit codes: query/head return 0/3/4 (bad SQL → 3, bad file → 4).

Test plan

  • cargo test — 76 passed, 2 ignored (cloud integration), 0 failed
  • cargo fmt --check
  • cargo clippy -- -D warnings
  • End-to-end: sentinel query examples/data.csv --sql "SELECT * FROM data WHERE age > 30" emits JSONL
  • End-to-end: sentinel head examples/data.csv -n 2 emits first 2 rows as JSONL
  • Exit codes verified: bad SQL → 3, missing file → 4, success → 0

🤖 Generated with Claude Code

Introduces `sentinel query <file> --sql "..."` for ad-hoc SQL over the
registered `data` table and `sentinel head <file> [-n N]` as a thin
convenience wrapper, both streaming rows as JSONL for agent consumption.
Row cap applied via `DataFrame::limit` so `WITH`/`UNION`/`ORDER BY` pass
through unchanged.

Also factors row-to-JSON conversion out of `runner.rs` into a shared
`arrow_json` helper built on `arrow::json::WriterBuilder`, replacing
~170 lines of hand-rolled per-DataType downcasting and broadening type
coverage (timestamps, dates, decimals) for `--show-violations` samples.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@SpollaL SpollaL merged commit b2d6d35 into master Apr 24, 2026
1 check passed
@SpollaL SpollaL deleted the feat/query-head-subcommands branch April 24, 2026 12:20
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