Skip to content

fix: throw on schema mismatch in RecordBatchStreamWriter.write()#389

Open
rustyconover wants to merge 1 commit intoapache:mainfrom
Query-farm:fix/schema-mismatch-throw
Open

fix: throw on schema mismatch in RecordBatchStreamWriter.write()#389
rustyconover wants to merge 1 commit intoapache:mainfrom
Query-farm:fix/schema-mismatch-throw

Conversation

@rustyconover
Copy link
Contributor

Summary

  • RecordBatchStreamWriter.write() previously silently closed the writer and dropped the batch when a schema mismatch was detected with autoDestroy: true (the default), causing data loss with no error
  • Now throws an Error with both expected and received schemas, making mismatches immediately visible
  • Added JSDoc for the autoDestroy option explaining its behavior

Test plan

  • Added schema-mismatch-tests.ts with 4 tests covering:
    • autoDestroy=true: throws on schema mismatch
    • autoDestroy=false: resets schema and writes multi-stream output (existing behavior preserved)
    • Writing to a closed writer throws
    • Error message includes both schemas
  • All tests pass (npx jest --testPathPattern='schema-mismatch')

Closes #388

🤖 Generated with Claude Code

Previously, writing a RecordBatch with a mismatched schema to a writer
with autoDestroy=true (the default) would silently close the writer and
drop the batch, causing data loss with no error or warning.

Now throws an Error with both the expected and received schemas, making
the mismatch immediately visible to the caller.

Closes apache#388

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

RecordBatchStreamWriter.write() silently drops batches on schema mismatch

1 participant