Skip to content

Add Markdown table output format (-O markdown) #167

@vmvarela

Description

@vmvarela

Description

Add markdown (alias md) to the output format list. Render SQL query results as a GitHub-Flavored Markdown table.

sql-pipe data.csv -O markdown 'SELECT region, SUM(amount) FROM t GROUP BY region'
# | region | SUM(amount) |
# |--------|-------------|
# | East   | 250         |
# | West   | 250         |

Motivation

Markdown tables are the standard format for embedding data in documentation, READMEs, GitHub issues, PRs, Slack/Teams messages, and Jupyter notebooks. Currently users must use --table + manual cleanup or pipe through another tool. This is the most-requested output format for CLI tools that produce tabular data.

Acceptance Criteria

  • Add markdown to the OutputFormat enum in src/format.zig
  • Implement markdown table writer with proper pipe-delimited rows and header separator
  • Left-align text columns, right-align numeric columns (reuse table.zig numeric detection)
  • NULL values render as empty cells (not the string "NULL")
  • -O md works as a shorthand alias
  • Compatible with --header (always include header for markdown)
  • Integration tests cover the new format
  • Help text updated

Implementation Notes

  • The two-pass approach from table.zig (compute widths, then print) can be reused almost directly
  • About 40-50 lines of new code
  • Markdown doesn't strictly need visual alignment (pipes are the structure), but aligned output looks better

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highMust be in the next sprintsize: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