Skip to content

Add --columns flag to list input column names #85

@vmvarela

Description

@vmvarela

Description

When working with an unfamiliar CSV file, users often need to know what columns are available before writing a query. Currently they have to use head -1 or --header with a SELECT *. A dedicated --columns flag reads only the header row and exits, making it composable with other tools.

Example

$ cat sales.csv | sql-pipe --columns
id
region
amount
date
status

# Use in scripts:
$ COLS=$(cat sales.csv | sql-pipe --columns | paste -sd,)
# → id,region,amount,date,status

Acceptance Criteria

  • --columns reads only the CSV header row, prints each column name on its own line to stdout, and exits 0
  • Inferred type is optionally shown with --columns --verbose: id INTEGER, amount REAL, region TEXT
  • --columns is mutually exclusive with a query argument (print usage error if both provided)
  • Works with --delimiter and --tsv flags
  • Documented in --help, README.md Flags table, and docs/sql-pipe.1.scd
  • Test: correct column list printed, correct exit code

Notes

  • Only the header row needs to be read — no need to load data rows
  • Column type annotation requires reading the first 100 rows for inference; document this overhead

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumShould be done soonsize:xsTrivial — less than 1 hourstatus:readyRefined and ready for sprint selectiontype:featureNew functionality

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions