Skip to content

feat: violation row export with --show-violations#3

Closed
SpollaL wants to merge 1 commit into
masterfrom
feat/violation-row-export
Closed

feat: violation row export with --show-violations#3
SpollaL wants to merge 1 commit into
masterfrom
feat/violation-row-export

Conversation

@SpollaL
Copy link
Copy Markdown
Owner

@SpollaL SpollaL commented Apr 23, 2026

Summary

  • Adds --show-violations [N] CLI flag that fetches and attaches the first N violating rows to each failed rule result (default N=5 when flag given without value)
  • JSON output includes a sample_rows array on each failing rule result (field omitted when flag not used)
  • Table output gains a SAMPLE VIOLATIONS column with compact JSON of violating rows

Example (JSON mode)

sentinel validate data.csv -r rules.yaml --show-violations 3
{"name":"price_not_negative","status":"fail","violations":3,"total_rows":1000,"violation_rate":0.003,"sample_rows":[{"price":-5.0},{"price":-0.01},{"price":-0.5}]}
{"name":"id_not_null","status":"pass","violations":0,"total_rows":1000,"violation_rate":0.0}

Test plan

  • test_fetch_samples_not_null — null rows returned for NotNull check
  • test_fetch_samples_min — rows below min returned
  • test_fetch_samples_max — rows above max returned
  • test_fetch_samples_between — out-of-range rows returned
  • test_fetch_samples_not_empty — empty-string rows returned
  • test_fetch_samples_unique — duplicate rows returned
  • test_fetch_samples_regex — non-matching rows returned
  • test_fetch_samples_limit — only N rows returned when more violations exist
  • test_fetch_samples_no_violations — empty vec when no violations
  • test_fetch_samples_custom_returns_empty — Custom check returns empty vec

🤖 Generated with Claude Code

- Adds --show-violations [N] flag (default N=5) to fetch the first N failing rows per rule
- JSON output gains a sample_rows array on each failing rule result (omitted when flag not used)
- Table output gains a SAMPLE VIOLATIONS column showing compact JSON of violating rows
- fetch_violation_samples() in runner.rs executes SELECT * for each check type and converts Arrow record batches to JSON
- Custom check returns empty samples
- 10 new tests covering all check types, limit behavior, no-violation case, and custom check

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SpollaL
Copy link
Copy Markdown
Owner Author

SpollaL commented Apr 23, 2026

Merged manually into master via rebase.

@SpollaL SpollaL closed this Apr 23, 2026
@SpollaL SpollaL deleted the feat/violation-row-export branch April 23, 2026 20:19
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