Skip to content

fix(proton): eliminate float64 precision loss and add column order guard#67

Merged
yokofly merged 1 commit intomainfrom
fix/float64-precision-sync
Apr 1, 2026
Merged

fix(proton): eliminate float64 precision loss and add column order guard#67
yokofly merged 1 commit intomainfrom
fix/float64-precision-sync

Conversation

@yokofly
Copy link
Copy Markdown
Collaborator

@yokofly yokofly commented Apr 1, 2026

Two fixes for the columnar insert fast path:

  1. Float64 precision: The buffer-replay goroutine could process the first rows before ApplyTargetCastPlan set the fast cast plan, causing those rows to fall through to CastRow which applies max_decimals=11 truncation. Add a castPlanReady channel so the goroutine waits for the plan (or pause signal) before replaying buffer rows. Signal deterministically from:

    • ApplyTargetCastPlan (Proton targets, first stream)
    • PushStreamChan (subsequent streams with plan already set)
    • Unpause (all database targets, after setup is complete)
    • WriteToFile (file/stdout targets, no Pause/Unpause cycle)
    • WaitReady (standalone consumers like Collect)
  2. Column order guard: The columnar buffer uses positional indexing, so column order mismatches would silently corrupt data. Add verifyColumnOrder() check per-batch that fails fast on mismatch.

Includes regression tests for both fixes.

Two fixes for the columnar insert fast path:

1. Float64 precision: The buffer-replay goroutine could process the
   first rows before ApplyTargetCastPlan set the fast cast plan,
   causing those rows to fall through to CastRow which applies
   max_decimals=11 truncation. Add a castPlanReady channel so the
   goroutine waits for the plan (or pause signal) before replaying
   buffer rows. Signal deterministically from:
   - ApplyTargetCastPlan (Proton targets, first stream)
   - PushStreamChan (subsequent streams with plan already set)
   - Unpause (all database targets, after setup is complete)
   - WriteToFile (file/stdout targets, no Pause/Unpause cycle)
   - WaitReady (standalone consumers like Collect)

2. Column order guard: The columnar buffer uses positional indexing,
   so column order mismatches would silently corrupt data. Add
   verifyColumnOrder() check per-batch that fails fast on mismatch.

Includes regression tests for both fixes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yokofly yokofly merged commit ab5b91f into main Apr 1, 2026
@yokofly yokofly deleted the fix/float64-precision-sync branch April 1, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant