Skip to content

Conversation

@michalcabir-ui
Copy link

@michalcabir-ui michalcabir-ui commented Dec 7, 2025

Summary & Motivation

Added a configurable write_mode option to BigQueryIOManager to support schema evolution and different writing strategies for non-partitioned tables.

Currently, the IO manager forces a TRUNCATE operation, which deletes rows but preserves the schema. This causes failures when the DataFrame schema changes (e.g., adding/removing columns).

How I Tested These Changes

Unit Testing: Created a new test file dagster_gcp_tests/bigquery_tests/test_bigquery_write_modes.py using unittest.mock.
Verified that write_mode="truncate" triggers a TRUNCATE TABLE query.
Verified that write_mode="replace" triggers a DROP TABLE IF EXISTS query.
Verified that write_mode="append" triggers no cleanup query.
Verified that partitioned tables ignore the write mode and use the legacy DELETE FROM logic.
Added a factory test to ensure the BigQueryClient is initialized with the correct default write_mode for backward compatibility.

Changelog

feat(gcp): Add write_mode configuration to BigQueryIOManager (supports truncate, replace, append) to allow schema evolution and append-only workflows.

Added support for truncate, replace, and append modes to allow schema evolution and append-only workflows. Includes unit tests and documentation updates.
@michalcabir-ui michalcabir-ui marked this pull request as ready for review December 7, 2025 19:53
@michalcabir-ui michalcabir-ui requested a review from a team as a code owner December 7, 2025 19:53
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