Skip to content

experimental_csv and spanvalue: non-breaking enhancements #41

@apstndb

Description

@apstndb

Context

Remaining spanvalue v0.5.0 opportunities not covered by #38 (dependency bump) or #39 (WriteRowIterator). Grouped for one or more follow-up PRs; no change to default CSV/jq output unless paired with the breaking-track issue.

Done

  • spanvalue v0.5.0 + NewCSVWriter error handling (#38)
  • writeCsvFromRowItersvwriter.WriteRowIterator (#39)

Proposed work (pick subset per PR)

A. Query stats / plan for CSV + WITH_STATS modes (medium)

WriteRowIterator returns RowIteratorResult (QueryPlan, QueryStats, RowsRead). CSV currently discards this; json eager mode embeds stats in the ResultSet shape.

Ideas (additive):

  • Emit stats to stderr as JSON when --query-mode is WITH_STATS or WITH_PLAN_AND_STATS and --format=experimental_csv.
  • Or --stats-file / documented convention for machine-readable side channel.

Tests: emulator or fixture iterator with stats fields populated.

B. CSV writer options (small)

  • --no-csv-headerwriter.WithHeader(false) on NewCSVWriter.
  • Document interaction with zero-row SELECT (header-only vs headerless).

C. New export formats (larger, separate PRs ok)

Format spanvalue API Notes
experimental_jsonl NewJSONLWriter One JSON object per line; align formatter with CSV preset flag when added
SQL INSERT dump NewSQLInsertWriter Needs typed rows / GCV path; not a drop-in for current string jq pipeline

D. Diagnostics hooks (small / optional)

RunRowIterator decorators: ObserveWriteRow, WithRowOrdinal for logging row progress on long exports—only if product wants visible progress without changing file format.

E. jq column naming consistency (small / if needed)

For unnamed STRUCT fields, align jq-visible column names with spanvalue using spanvalue.ColumnNames + same UnnamedFieldNamer as writer.WithUnnamedFieldNamer—only if golden/integration tests show a mismatch today.

References

  • spanvalue writer README: RowIterator, RowIteratorResult, hooks
  • Prior trial notes: /tmp/spanvalue-v0.5.0-alpha.2-feedback.md (local)

Acceptance (per sub-item)

  • A: Stats/plan visible for CSV when stats query modes are selected; tests added.
  • B: Headerless CSV flag works; documented.
  • C/D/E: As scoped in child PRs linked from this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions