Add optional streaming insert API for BigQuery #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements #8 - adds opt-in streaming insert API alongside the existing load job API for BigQuery.
Features
useStreamingAPIsconfig option - defaults tofalsefor backward compatibilityImplementation Approach
Followed Test-Driven Development (TDD):
_insertStreaming()and routing logic (all passed)Changes
Modified Files
src/bigquery.js- Added streaming insert support with dispatcher logicconfig.yaml- Documentation and examples for both insert methodstest/bigquery-streaming.test.js- 16 comprehensive unit testsdocs/plans/2025-11-14-streaming-insert-api-design.md- Complete design documentKey Implementation Details
Configuration:
Dispatcher logic:
insertBatch()routes to appropriate method based on configRetry logic: Exponential backoff for transient errors (1s, 2s, 4s)
Error handling: Partial failure detection and detailed logging
Testing
All 107 tests passing:
Tests cover:
Migration Guide
Existing deployments: No changes required - defaults to load job API
Enable streaming for a table:
Decision Guide
Use Load Job API (default):
Use Streaming API:
Cost Implications
Example: 144K records/day × 1 KB/record = 144 MB/day = $0.30/month
Documentation
Complete design document included:
docs/plans/2025-11-14-streaming-insert-api-design.md