feat: add query and head subcommands for agent data exploration#5
Merged
Conversation
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>
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.
Summary
sentinel query <file> --sql "..."subcommand — runs arbitrary SQL against the registereddatatable and streams rows as JSONL; row cap applied viaDataFrame::limit(default--max-rows 1000) so userWITH/UNION/ORDER BYclauses pass through unchanged.sentinel head <file> [-n N]subcommand — thin wrapper overquery, returns first N rows as JSONL (default 10).fetch_violation_samples' per-DataType downcasting (~170 lines) intosrc/arrow_json.rs, rebuilt onarrow::json::WriterBuilder;--show-violationssamples now also cover timestamps, dates, and decimals.query/headreturn0/3/4(bad SQL →3, bad file →4).Test plan
cargo test— 76 passed, 2 ignored (cloud integration), 0 failedcargo fmt --checkcargo clippy -- -D warningssentinel query examples/data.csv --sql "SELECT * FROM data WHERE age > 30"emits JSONLsentinel head examples/data.csv -n 2emits first 2 rows as JSONL🤖 Generated with Claude Code