atomic-ctasThe exasol__create_table_as macro emits two separate SQL statements:
CREATE OR REPLACE TABLE ... WITH NO DATA โ auto-commits an empty tableINSERT INTO ... โ populates the tableIf the dbt process crashes between steps 1 and 2 (signal, network drop, OOM), the target table is left permanently empty. Downstream models silently produce zero-row results.
Replace the two-step pattern with a single atomic CREATE OR REPLACE TABLE ... AS <sql> statement. The table either has the new data or the previous version is preserved unchanged.
CREATE OR REPLACE TABLE t AS <sql> [DISTRIBUTE BY ...] [PARTITION BY ...]ALTER TABLE for constraints (NOT NULL, PK, FK) โ additive operations that can't cause data lossatomic-ctas
Guarantees create_table_as is atomic โ populated with data or previous version preserved
relation-management
get_replace_table_sql now produces single atomic CTAS via delegation
CREATE OR REPLACE TABLE t AS <sql> DISTRIBUTE BY ... PARTITION BY ... โ one statement, inline distribution. If SELECT fails, existing table is preserved.
AS subquery. Solution: atomic CTAS first, then ALTER TABLE ADD CONSTRAINT โ safe because data is guaranteed present.
ALTER TABLE ADD CONSTRAINT ... PRIMARY KEY (...). Actually safer โ PK validated against real data.
add_constraints split into inline clauses (DISTRIBUTE/PARTITION) and post-creation ALTERs (PK). |SEPARATEMEPLEASE| splitter retained only for ALTER statements.
ALTER TABLE MODIFY COLUMN ... NOT NULL. If data has NULLs, ALTER fails. Actually correct behavior โ old pattern never validated against data.
exasol_expected_sql in constraint test fixtures hardcodes old pattern. Test-only change.
adapters.sql โ exasol__create_table_ascreate_table_helpers.sql โ add_constraints, partition_by_conf, distribute_by_conftable.sql, incremental.sql, snapshot.sqlcreate_table_as โ fix applies transparentlyconstraints/fixtures.py โ expected SQL updateconnections.py splitter mechanismcreate_table_helpers.sql macrospartition_by_conf โ inline CTAS clause (no trailing semicolon)distribute_by_conf โ inline CTAS clauseadd_constraints โ post-creation ALTERs only (remove PARTITION/DISTRIBUTE)exasol__create_table_as macroWITH NO DATA and INSERT INTO patternstemporary parameter handling distinctionexasol_expected_sql to match new patternWITH NO DATA + INSERT)atomic-ctas (6 requirements, 11 scenarios)relation-management (1 scenario changed)
Generated from openspec/changes/atomic-ctas/ ยท dbt-exasol ยท 2026-04-13