ADR-0006 — try CREATE OR ALTER, except CREATE OR REPLACE for stateless objects
Update date : 2026-05-27 20:11
Status: accepted Date: 2026-05-27 Refines: ADR-0005 (stateless row)
Context
Stateless objects (view, UDF, SP) support CREATE OR ALTER for most changes, but some changes
require CREATE OR REPLACE — e.g. changing the handler path on a SP or UDF.
Tracking which specific field changes require OR REPLACE per object type is complex and fragile. Cortex confirmed the try/except pattern is not an antipattern here.
Decision
For stateless objects only:
try:
resource.create_or_alter()
except SnowflakeError:
resource.create_or_replace()
Stateful objects (table, schema, stage…) are never subject to this pattern — they only use
CREATE OR ALTER / IF NOT EXISTS. OR REPLACE on a stateful object would destroy data.
Consequences
- No per-field tracking of "which change requires OR REPLACE" — the SDK signals it at runtime.
CREATE OR REPLACEon a stateless object drops and recreates it — dependencies (e.g. grants on a SP, views depending on a view) are lost and must be re-applied by the provider.- SQL fallback objects (ADR-0005) are unaffected.
Known exceptions — read Snowflake docs before implementing
Stream: has a CDC offset. CREATE OR REPLACE resets the offset — treat as stateful,
never subject to the try/except pattern.
Dynamic Table: if a DT is upstream of another DT, CREATE OR REPLACE can break the
downstream refresh chain. Dependency order and cascade behaviour need to be verified
against current Snowflake docs before implementing.