fix(bigquery): relax metadata columns to NULLABLE to unblock loads (v0.4.1) - #83
Merged
Merged
Conversation
The batch `bigquery` destination declared the metadata columns (_source_record_id, _source_timestamp, _bizon_extracted_at, _bizon_loaded_at, _bizon_id) as REQUIRED in the load-job schema. BigQuery forbids promoting an existing NULLABLE column to REQUIRED, so every load against a table whose metadata columns were already NULLABLE failed with: 400 Provided Schema does not match Table ... Field _source_record_id has changed mode from NULLABLE to REQUIRED This broke all affected pipelines (most visibly in stream mode, which loads directly into the final table). - Declare the metadata columns NULLABLE (bizon always populates them, so only the BQ-level NOT NULL constraint is dropped, not data). - Set ALLOW_FIELD_RELAXATION + ALLOW_FIELD_ADDITION on the load job so any table created REQUIRED by the previous behavior self-heals on its next load without a manual migration. - Add a regression test asserting NULLABLE modes + relaxation options. - Bump version to 0.4.1 and add CHANGELOG entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
All BigQuery batch (
bigquery) pipelines were failing with:Root cause
get_bigquery_schema()declared the metadata columns (_source_record_id,_source_timestamp,_bizon_extracted_at,_bizon_loaded_at,_bizon_id) asmode="REQUIRED", and_build_load_job_config()passes that schema on every load (load_table_from_uri). The production tables already have those columns asNULLABLE, and BigQuery does not allow promoting an existing NULLABLE column to REQUIRED — only the reverse (relaxation) is permitted. So the load is irreconcilable without dropping/recreating the table. The failure is most visible instreammode, where the load targets the final table directly (temp_table_id == table_id).The
REQUIREDmode has existed since Dec 2024; it surfaced now because these loads run against pre-existing NULLABLE tables.Fix
NULLABLEso the load schema matches existing tables. bizon always populates these fields, so this drops only the BQ-level NOT NULL constraint, not data.ALLOW_FIELD_RELAXATION+ALLOW_FIELD_ADDITIONto the load job so any table createdREQUIREDby the old code self-heals on its next load (no manual migration), and additive source-schema drift is tolerated.bigqueryconnector only (bigquery_streaming/bigquery_streaming_v2unchanged).v0.4.1+ CHANGELOG entry.Recovery for the already-stalled pipelines
bizon is at-least-once with cursor checkpointing, so recovery is: deploy this fix → re-run each pipeline. Each resumes from the last successful cursor, re-fetches the failed range, and loads into the (now matching) NULLABLE table; duplicate writes are expected and acceptable. No table surgery is needed for the NULLABLE tables (the common case). Tables created
REQUIREDby the old code self-heal viaALLOW_FIELD_RELAXATIONon the next load.Tests
tests/connectors/destinations/bigquery/test_bigquery_schema.py— passes.*_livetests +test_bigquery_client/test_bigquery_factoryerrors are pre-existing (require live BigQuery credentials / an unrelatedSyncMetadatatest bug) — verified identical on unmodified source.🤖 Generated with Claude Code