liveBook · Manning

Declarative configuration

As explained in Snowflake Data Engineering

Declarative database change management specifies the desired state of database objects rather than describing only the sequence of operations needed to reach it.

Declarative configuration manages database objects by declaring the desired state rather than scripting every operation needed to reach it. Snowflake supports this approach for database change management with CREATE OR ALTER. section 15.2.1

Use declarative object definitions to simplify pipeline change management:

  • Define each object at its intended version without knowing the previous version. section 15.2.1
  • Apply the current definition regardless of the sequence of earlier changes. section 15.2.1
  • Recreate an object after a partial rollback by running its definition for the required point in time. section 15.2.1
  • Organize scripts by schema, object type, and database object within the repository. section 15.2.2

Adding and dropping a column

An imperative workflow appends ALTER TABLE statements. A declarative workflow replaces the table definition with its desired state: CREATE OR ALTER TABLE EMPLOYEE(id integer, name varchar, SSN varchar, birth_dt date); Later, rerun the definition without SSN to declare that the column should be absent. section 15.2.1

Table 15.2 An example illustrating the comparison between the imperative and declarative approaches to database change management
Step
Imperative approach
Declarative approach
Creating a table
create table EMPLOYEE(
id integer,
name varchar,
SSN varchar);
create table EMPLOYEE(
id integer,
name varchar,
SSN varchar);
Adding a column
alter table EMPLOYEE
add column birth_dt date;
create or alter
table EMPLOYEE(
id integer,
name varchar,
SSN varchar,
birth_dt date);
Dropping a column
alter table EMPLOYEE
drop column SSN;
create or alter
table EMPLOYEE(
id integer,
name varchar,
birth_dt date);

Compare table creation, column addition, and column removal through imperative ALTER statements and declarative CREATE OR ALTER definitions. section 15.2.1

For tables, use CREATE OR ALTER. For other object types, use CREATE OR REPLACE so development scripts can be rerun without failing when objects already exist. section 15.2.2

How Snowflake Data Engineering covers it

How deep it goes
Explains desired-state definitions, rollback benefits, SQL commands, rerunnable scripts, and repository organization.
Examples
Compares EMPLOYEE table creation, column addition, column removal, and schema-organized SQL scripts.
What you can do after
Operate/configure Snowflake objects through versioned, rerunnable definitions and recreate states after partial rollbacks.
How it connects
Connects database change management with imperative SQL, CREATE OR ALTER, CREATE OR REPLACE, repositories, schemas, and object types.

Also explained in

Compare how 6 books explain declarative configuration →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Snowflake Data Engineering. The section links point to the parts of the book it draws on.