Understand the dbt-databricks Seed Flow (V1 vs V2)
mainThe dbt seed command follows a specific execution lifecycle to load CSV data into Databricks. The project has transitioned from V1 to V2. The primary difference in V2 is the removal of unsupported operations, specifically the creation of indexes and the explicit commit step, resulting in a cleaner execution path.
V1 Seed Flow Lifecycle
- In-memory Preparation: Creates an in-memory table from the CSV and stores the result.
- Prehooks: Executes prehooks (first with
inside_transaction=False, then withinside_transaction=True). - Table Existence Check:
- If the table does not exist: Creates the table and performs chunked inserts.
- If the table exists:
- If it is not a table: Raises a compiler error.
- If it is a table and is a Delta table: Performs
create or replace table...followed by chunked inserts. - If it is a table but not Delta: Drops the existing table, creates a new one, and performs chunked inserts.
- Post-processing: Applies grants, creates indexes (noted as a legacy/questionable step in V1), runs posthooks (
inside_transaction=True), commits the transaction, and finally runs posthooks (inside_transaction=False).
V2 Seed Flow Lifecycle (Current)
V2 simplifies the process by removing unsupported calls:
- In-memory Preparation: Creates an in-memory table from the CSV and stores the result.
- Prehooks: Executes prehooks (first with
inside_transaction=False, then withinside_transaction=True). - Table Existence Check:
- If the table does not exist: Creates the table and performs chunked inserts.
- If the table exists:
- If it is not a table: Raises a compiler error.
- If it is a table and is a Delta table: Performs
create or replace table...followed by chunked inserts. - If it is a table but not Delta: Drops the existing table, creates a new one, and performs chunked inserts.
- Post-processing: Applies grants and runs posthooks (
inside_transaction=Truetheninside_transaction=False).