Design a System to Automate Schema Evolution in Snowflake for Real-time Data Ingestion
Instruction: Provide a high-level design for a system that can automate schema evolution in Snowflake. Your design should consider scenarios where the schema of incoming data streams changes frequently.
Updated
Official answer
Separate durable ingestion from governed publication. Preserve raw events with source, event identity, schema version and ingest time, then validate and transform into typed serving tables. Quarantine incompatible records without silently dropping them; track lag, rejected records and replay progress.
Classify changes. A new optional field can be backward compatible; a rename, type change or semantic change needs an explicit migration. Do not automatically issue arbitrary ALTER statements based on one incoming payload.
For supported file loads, automatic evolution can add columns and remove NOT NULL constraints for fields absent from new files. It requires ENABLE_SCHEMA_EVOLUTION, COPY column-name matching and an appropriate EVOLVE SCHEMA or ownership privilege. CSV has additional options. Ordinary INSERT does not automatically evolve schemas.
Streaming support depends on the architecture and connector: current high-performance Snowpipe Streaming and the supported classic Kafka connector have documented evolution paths. Confirm their type, table and tracking limits instead of treating every streaming SDK as equivalent.
Validate compatibility in a separate target, backfill deterministically, compare counts and business invariants, then promote a versioned view or controlled consumer contract. Plan recovery explicitly: DDL boundaries and downstream effects matter, and Fail-safe is not an application-controlled schema rollback mechanism. Keep the prior compatible serving path until the migration is verified, and reconcile writes before any reversal.