Skip to content

Add --null-value flag for custom NULL representation #170

@vmvarela

Description

@vmvarela

Description

Add a --null-value flag that controls how NULL values are rendered in output.

# Default behavior (empty for CSV, null for JSON):
sql-pipe data.csv 'SELECT * FROM t'

# Custom NULL representation:
sql-pipe data.csv --null-value 'N/A' 'SELECT * FROM t'
sql-pipe data.csv --null-value '' 'SELECT * FROM t'
sql-pipe data.csv --null-value '-' 'SELECT * FROM t'

Motivation

Different tools and consumers expect different NULL representations. Some CSV consumers treat empty strings as NULL, others treat the literal string "NULL" as NULL. This flag gives users control over how missing data is represented in the output.

Acceptance Criteria

  • --null-value <string> flag is parsed in args.zig
  • CSV/TSV output: NULL values render as the configured string instead of empty
  • Table output: NULL values render as the configured string instead of "NULL"
  • JSON output: --null-value is ignored (JSON null is semantically correct) or produces a warning
  • Default behavior is unchanged when flag is not provided
  • Integration tests cover the new flag with each output format
  • Help text updated

Implementation Notes

  • In format.zig's csvPrintRow (~line 236), replace the hardcoded empty/NULL with the configured value
  • In json_mod.printJsonRow (~line 437), decide whether to respect the flag or keep JSON null
  • Add null_value: ?[]const u8 field to ParsedArgs

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highMust be in the next sprintsize:xsTrivial — less than 1 hourstatus: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