Skip to content

Add --validate mode to check CSV syntax without running a query #88

@vmvarela

Description

@vmvarela

Description

Users working with untrusted or generated CSV often want to verify the file is well-formed before running queries. Today this requires piping through a no-op query (SELECT 1) and interpreting exit codes. A dedicated --validate flag makes the intent explicit and gives better error output.

Example

# Valid file
$ cat good.csv | sql-pipe --validate
OK: 1,234 rows, 5 columns (id INTEGER, name TEXT, amount REAL, region TEXT, date TEXT)
$ echo $?
0

# Invalid file
$ cat bad.csv | sql-pipe --validate
error: CSV parse error at row 42: unclosed quoted field
$ echo $?
2

Acceptance Criteria

  • --validate parses the entire CSV input and prints a summary to stdout on success: OK: <n> rows, <m> columns (<col> <TYPE>, ...)
  • On parse error, print the existing CSV error message (row number + description) and exit 2
  • --validate does not run any SQL query — no query argument required or used
  • Works with --delimiter, --tsv, --no-type-inference
  • Exit 0 on success, exit 2 on CSV error
  • Documented in --help, README.md, and docs/sql-pipe.1.scd
  • Tests: valid CSV exits 0 with correct summary; malformed CSV exits 2 with row number

Notes

  • Reuses the existing CSV parser and type inference pipeline; skip sqlite3_exec entirely
  • The column type summary requires running type inference (first 100 rows)

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumShould be done soonsize:sSmall — 1 to 4 hoursstatus:readyRefined and ready for sprint selectiontype:featureNew functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions