Request a demo

Glossary · Data observability and quality

What is Schema change / schema drift?

A schema change is any change to a table's structure: a column added, dropped, renamed or retyped, or a mode relaxed from REQUIRED to NULLABLE. Schema drift is the gradual, often unannounced accumulation of such changes in source data, which breaks or silently corrupts downstream pipelines.

Also called: schema drift, schema evolution, breaking schema change, column change, schema change detection

Breaking and non-breaking changes

Not every schema change breaks something:

  • Usually safe: adding a nullable column, relaxing REQUIRED to NULLABLE, widening INT64 to NUMERIC.
  • Breaking: dropping or renaming a column that downstream SQL references, narrowing a type, or changing what a column means while keeping its name.
  • Silently breaking: a source starts sending a timestamp as a string, a new enum value appears, or SELECT * in a view starts returning an extra column that shifts a positional export.

The silent cases are the expensive ones, because nothing fails: values turn into NULL after a SAFE_CAST, joins stop matching, and reports drift until someone notices.

How schemas change on BigQuery

Changes reach a table through DDL such as ALTER TABLE, through load and query jobs that append with ALLOW_FIELD_ADDITION or ALLOW_FIELD_RELAXATION, through overwrites that replace the schema, and through tools like dbt that rebuild tables. Loads whose files do not match the table fail with errors such as provided schema does not match table, which is the good outcome: the change was caught.

Detect schema drift with INFORMATION_SCHEMA

Store a daily snapshot of INFORMATION_SCHEMA.COLUMNS, then compare the two latest snapshots:

-- Run daily
INSERT INTO ops.column_snapshots (snapshot_date, table_name, column_name, data_type, is_nullable)
SELECT CURRENT_DATE(), table_name, column_name, data_type, is_nullable
FROM analytics.INFORMATION_SCHEMA.COLUMNS;

-- Compare today with yesterday
WITH today AS (
  SELECT * FROM ops.column_snapshots WHERE snapshot_date = CURRENT_DATE()
),
yesterday AS (
  SELECT * FROM ops.column_snapshots WHERE snapshot_date = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
)
SELECT
  COALESCE(t.table_name, y.table_name) AS table_name,
  COALESCE(t.column_name, y.column_name) AS column_name,
  CASE
    WHEN y.column_name IS NULL THEN 'added'
    WHEN t.column_name IS NULL THEN 'dropped or renamed'
    ELSE 'type or mode changed'
  END AS change,
  y.data_type AS old_type,
  t.data_type AS new_type
FROM today AS t
FULL OUTER JOIN yesterday AS y
  ON t.table_name = y.table_name AND t.column_name = y.column_name
WHERE t.column_name IS NULL
  OR y.column_name IS NULL
  OR t.data_type != y.data_type
  OR t.is_nullable != y.is_nullable;

A daily diff finds changes a day late and only in datasets you snapshot. Audit logs record table updates as they happen, which is how tools such as Masthead alert on schema changes across every project in near real time.

Preventing damage

  • Agree on schemas with producers in a data contract and enforce it in CI.
  • Avoid SELECT * in views and models that feed exports or APIs.
  • Use column-level lineage to see which downstream columns and dashboards depend on a column before you drop or rename it.
  • Treat an unexpected schema change as a data incident, even when nothing has failed yet.

FAQ

Which schema changes does BigQuery allow on an existing table?

You can add NULLABLE or REPEATED columns (always at the end), relax REQUIRED columns to NULLABLE, rename and drop columns, change defaults and descriptions, and widen some types with ALTER COLUMN SET DATA TYPE, for example INT64 to NUMERIC. Adding a REQUIRED column to an existing table is not allowed.

How do I detect schema changes in BigQuery?

Snapshot INFORMATION_SCHEMA.COLUMNS on a schedule and compare snapshots, or watch Cloud Audit Logs for table update events. Note that INFORMATION_SCHEMA can lag behind a change briefly; tables.get returns the current schema immediately.

Read next

Browse the full glossary

Observability for every BigQuery table, in about 15 minutes

Masthead detects freshness, volume and schema anomalies, monitors pipeline errors and maps column-level lineage across all your projects, from logs and metadata only.