Skip to content

feat: add BigQuery streaming - #7019

Closed
rudder-devbox[bot] wants to merge 2 commits into
masterfrom
harness/INT-6410-feat-add-bigquery-streaming-async-d-kuad
Closed

rudder-devbox[bot] wants to merge 2 commits into
masterfrom
harness/INT-6410-feat-add-bigquery-streaming-async-d-kuad

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds BQ_STREAMING, a new async destination manager that streams events into BigQuery in near real-time using the Storage Write API, instead of going through the warehouse batch (GCS load job) pipeline.

How it works

For each upload, the batch router hands the manager a file of transformed events. The manager:

  1. Groups events by table and chunks them by size.
  2. Fetches the namespace schema when the cache is cold/expired (TTL-based cache; stream writers are only torn down when a table's schema actually changed).
  3. Creates the dataset/tables and adds new columns as needed (discards table is created/migrated once, upfront).
  4. Converts values that don't match the table schema where possible, and writes incompatible ones to rudder_discards.
  5. Encodes rows directly into protobuf (no JSON round-trip) and appends them per table through cached managed-write streams, with chunk appends pipelined.

Failures are classified into retryable vs abort via gRPC codes; schema-mismatch errors during BigQuery's schema-propagation window are retried. Tables are processed concurrently with bounded workers, and job statuses (succeeded/failed/aborted) are reported per table.

Testing

  • Unit tests for transform, chunking, schema cache, upload flows, and error classification.
  • Integration tests (integration_test/bqstreaming) covering: table/namespace auto-creation, schema evolution (new columns, dropped columns/tables/datasets, datatype changes), discards + discards-table migration, many tables, all datatypes, JSON columns, identify events, and custom partitioning (received_at/day).

Linear Ticket

INT-6410

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov

codecov Bot commented May 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.51724% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.46%. Comparing base (d156057) to head (87b6f89).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...r/asyncdestinationmanager/bqstreamv2/bqstreamv2.go 86.50% 56 Missing and 27 partials ⚠️
...asyncdestinationmanager/bqstreamv2/streamwriter.go 51.35% 10 Missing and 8 partials ⚠️
...router/asyncdestinationmanager/bqstreamv2/types.go 81.81% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7019      +/-   ##
==========================================
- Coverage   79.72%   79.46%   -0.27%     
==========================================
  Files         567      572       +5     
  Lines       64690    65410     +720     
==========================================
+ Hits        51577    51975     +398     
- Misses      10035    10333     +298     
- Partials     3078     3102      +24     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@achettyiitr
achettyiitr force-pushed the harness/INT-6410-feat-add-bigquery-streaming-async-d-kuad branch 10 times, most recently from 655b065 to d935740 Compare June 4, 2026 07:27
🔒 Scanned for secrets using gitleaks 8.29.1
@achettyiitr
achettyiitr force-pushed the harness/INT-6410-feat-add-bigquery-streaming-async-d-kuad branch from d935740 to 6e62c64 Compare June 4, 2026 08:05
@achettyiitr achettyiitr changed the title feat: add BIGQUERY_STREAMING async destination manager feat: add BigQuery streaming Jun 4, 2026
@achettyiitr
achettyiitr force-pushed the harness/INT-6410-feat-add-bigquery-streaming-async-d-kuad branch 7 times, most recently from d1b92a4 to d7e482c Compare June 5, 2026 07:48
🔒 Scanned for secrets using gitleaks 8.29.1
@achettyiitr
achettyiitr force-pushed the harness/INT-6410-feat-add-bigquery-streaming-async-d-kuad branch from d7e482c to 87b6f89 Compare June 5, 2026 10:04
@achettyiitr
achettyiitr marked this pull request as ready for review June 5, 2026 10:16
@achettyiitr
achettyiitr marked this pull request as draft June 5, 2026 14:36
achettyiitr added a commit that referenced this pull request Jun 9, 2026
…#7056)

# Description
 
PR 1/3 of the BQSTREAM_V2 stack (splits #7019).
 
Adds the `BQSTREAM_V2` destination type, warehouse-side enablement, and
all building blocks of the async destination manager — with no runtime
behavior yet:
 
**Warehouse enablement**
- Added `BQSTREAM_V2` constant and treated it as a pseudo-warehouse
destination (`warehouse/utils`).
- Routed `BQSTREAM_V2` to the BigQuery warehouse manager in
`warehouse/integrations/manager`
(`FetchSchema`/`CreateSchema`/`CreateTable`/`AddColumns` reuse).
- Embedded warehouse transformer support: `loaded_at` column, JSON path
support, full event column type (`string`), users-table skip, BigQuery
reserved keywords.
 
**bqstreamv2 building blocks**
(`router/batchrouter/asyncdestinationmanager/bqstreamv2`)
- Package types and destination config decoding with namespace
normalization (+ unit tests).
- BigQuery data type mapping, in-memory table schema cache with TTL,
Storage Write API managed-writer wrapper.
- Event parsing from async files, per-table grouping and size-bounded
chunking, event-schema derivation (`events.go`).
- Discard extraction for schema-mismatched values and duplicate ID
detection.
- Dynamic protobuf row encoding with numeric/timestamp coercion
(`encode.go`), plus protojson equivalence test and benchmarks.
- Schema diffing (`findNewColumns`) and BigQuery error classification
(`schemautils.go`, + unit tests).
 
Inert until the Manager orchestration is added and registered (PR 2/3).
 
**Stack:** PR 1 (this) → PR 2 (upload orchestration + registration) → PR
3 (integration tests)
 
## Linear Ticket
 
- Resolves INT-6410
 
## Security
 
- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
 
## Validation
 
- `go build ./...`
- `go test ./router/batchrouter/asyncdestinationmanager/bqstreamv2/...`
- `go test
./processor/internal/transformer/destination_transformer/embedded/warehouse/...`

---------

Co-authored-by: Akash Chetty <[email protected]>
achettyiitr added a commit that referenced this pull request Jun 12, 2026
# Description
 
PR 2/3 of the BQSTREAM_V2 stack (splits #7019). Stacked on #<PR1>.
 
Implements the Manager upload orchestration on top of the building
blocks from PR 1, and wires it up:
 
**Upload orchestration**
- Transform using `common.GetMarshalledData(string(job.EventPayload),
job.JobID)`.
- Upload flow: reads the async file, groups and chunks events (helpers
from PR 1), and processes tables with bounded concurrency.
- Schema lifecycle via the warehouse BigQuery manager (`FetchSchema`,
`CreateSchema`, `CreateTable`, `AddColumns`), including
dataset-not-found create-and-retry handling and schema caching.
- Discard-path writes to `rudder_discards`; appends encoded rows through
cached per-table Storage Write API writers.
- Append error classification into failed vs aborted job IDs; schema
cache/writer invalidation on failures.
- Unit tests for the full upload flow (31 scenarios).
 
**Registration**
- Registered `BQSTREAM_V2` in the async destination manager factory via
`common.SimpleAsyncDestinationManager`.
- Added `BQSTREAM_V2` to the async destinations whitelist and
`misc.BatchDestinations()`.
- Registration unit test and README entry.
 
This PR turns the feature on for configured destinations. ~65% of the
diff is unit tests.
 
**Stack:** PR 1 (enablement + building blocks) → PR 2 (this) → PR 3
(integration tests)
 
## Linear Ticket
 
- Resolves INT-6410
 
## Security
 
- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
 
## Validation
 
- `go test ./router/batchrouter/asyncdestinationmanager/bqstreamv2/...`
- `go test ./router/batchrouter -run Async -count=1`

---------

Co-authored-by: Akash Chetty <[email protected]>
achettyiitr added a commit that referenced this pull request Jun 12, 2026
# Description
 
PR 3/3 of the BQSTREAM_V2 stack (splits #7019). Stacked on #<PR2>.
 
End-to-end coverage for the `BQSTREAM_V2` destination:
 
- Added `integration_test/bqstreamv2` covering the full flow (event
ingestion → batch router → BigQuery Storage Write API), including schema
creation, column addition, discards, and duplicate/invalid record
handling.
- Added rudder-transformer docker-compose testdata.
- Added `integration_test/bqstreamv2` to the CI test matrix in
`.github/workflows/tests.yaml`.
 
**Stack:** PR 1 (enablement + building blocks) → PR 2 (upload
orchestration + registration) → PR 3 (this)
 
## Linear Ticket
 
- Resolves INT-6410
 
## Security
 
- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
 
## Validation
 
- `go test ./integration_test/bqstreamv2/... -count=1` (requires
BigQuery credentials)

---------

Co-authored-by: Akash Chetty <[email protected]>
@achettyiitr
achettyiitr deleted the harness/INT-6410-feat-add-bigquery-streaming-async-d-kuad branch June 16, 2026 09:52
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.

2 participants