← Back to Pull requests

fix(arrow/csv): write and read time32 columns #1706

Closed
unknown closed this pull request without merging on Dec 03, 2026 18:44 UTC
View on GitHub
unknown unknown commented on Nov 28, 2026 16:52 UTC
Author

Rationale for this change

csv.NewInferringReader infers time32[s] for columns like 12:34:56, but csv.Writer can't write that type back. Writing the record it just read panics:

panic: arrow/csv: field has unsupported data type time32[s]

csv.NewReader has a related gap: it rejects a schema with a time32 field (field 0 (time) has invalid data type *arrow.Time32Type), even though the reader already parses time32 values when it infers the schema. So a time32 column can't be written, and can only be read through inference.

What changes are included in this PR?

  • The writer formats time32 values with Time32.FormattedString(unit). That gives HH:MM:SS for seconds and HH:MM:SS.sss for milliseconds, which is what arrow.Time32FromString (used by the reader) parses.

  • readTypeSupported accepts time32, so NewReader takes a schema with a time32 field. The reader already has a time32 parser, so this just stops validation from rejecting the type.
  • time64, duration and decimal32/decimal64 are left out. The reader doesn't parse them either, so there is no matching format to round-trip.

    Are these changes tested?

    Yes.

  • TestCSVWriterReaderTime32RoundTrip writes time32[s] and time32[ms] columns with a null, checks the CSV output, and reads it back with NewReader using the same schema.

  • TestCSVWriterWritesInferredTime32 reads a CSV file with NewInferringReader, checks that the column is inferred as time32[s], and checks that writing it gives back the same text.
  • Both tests use a checked allocator. Without the writer change both panic with the error above. Without the readTypeSupported change the round-trip test panics in NewReader.

    On Windows amd64 with Go 1.26.11, go test -tags assert,test ./arrow/csv/ -run '^Test' passes, go vet is clean, and golangci-lint reports no new issues. Example_reader needs the arrow-testing submodule, which isn't checked out locally, so it was skipped. It fails the same way on main.

    Are there any user-facing changes?

    No API changes. csv.Writer can now write time32 columns, and csv.NewReader accepts schemas with time32 fields.

    This PR was prepared with AI assistance (Claude Code).

    🤖 Generated with Claude Code

    Diff: 288 lines (+216 / -72) across 3 files Reviewer: ShivamSharma43 Review duration: 7312m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 288 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.339
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1706"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.8% (MEDIUM) · Higher = larger blast radius
    39.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.7% · Safe to merge
    15.7%