Skip to content

Incremental Python models fail #636

@SC-fmeyer

Description

@SC-fmeyer

Target

MotherDuck database

Version

dbt-duckdb 1.9.6

General

Running incremental Python models for a MotherDuck connection fail when using the dbt-duckdb extension in version 1.9.6. Going back to version 1.9.2 works.

There was a recent change in 1.9.5 mentioning the problem: #591

Reproduction steps

  • Create simple Python dbt model sample_model.py like
import pandas as pd

def model(dbt, session):
    dbt.config(materialized="incremental")

    df = pd.DataFrame({
        'id': [1, 2, 5],
        'value': ['A', 'B', 'C']
    })

    if dbt.is_incremental:
        existing_query = f"SELECT id FROM {dbt.this}"
        existing_ids = session.sql(existing_query).df()
        
        if not existing_ids.empty:
            df = df[~df['id'].isin(existing_ids['id'])]

    return df
  • Modify dbt_project.yml accordingly to your model folder
  • Run the model at least 2 times via dbt run --select sample_model

Result

Following error occurs:

08:10:33  Finished running 1 incremental model in 0 hours 0 minutes and 5.45 seconds (5.45s).
08:10:34  
08:10:34  Completed with 1 error, 0 partial successes, and 0 warnings:
08:10:34  
08:10:34  Failure in model sample_model (models/marts/dev/sample_model.py)
08:10:34  Runtime Error in model sample_model (models/marts/dev/sample_model.py)
  Catalog Error: Table with name sample_model__559a98c6be48 does not exist!
  Did you mean "sample_model__eb759410ca9c"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions