Debug and fix incorrect customer lifetime value calculations in a dbt dimensional model
harbor run -t snowflake-labs/dbt-fix-customer-ltvharbor download snowflake-labs/dbt-fix-customer-ltvThe dim_customers model has issues. Investigate and fix all problems.
The analytics team flagged the dim_customers model as producing incorrect results. Numbers don't reconcile with upstream data. There may be multiple issues. Find and fix them all.
/app/database/retail.duckdb/app/dbt_models_duckdb/app/dbt_models_snowflakeThis task supports both DuckDB and Snowflake. Run echo $DB_TYPE in a shell BEFORE you write any code or spawn any subagents — the live env determines which backend the verifier runs against. Do NOT assume a default from this prose. Both /app/dbt_models_duckdb/ and /app/dbt_models_snowflake/ exist on disk; the verifier only checks the project matching the live $DB_TYPE.
DB_TYPE=duckdb$DUCKDB_PATH (default: /app/database/retail.duckdb)DB_TYPE=snowflakeSNOWFLAKE_ACCOUNTSNOWFLAKE_USERSNOWFLAKE_PASSWORDSNOWFLAKE_DATABASE - The clone database to useSNOWFLAKE_SCHEMASNOWFLAKE_WAREHOUSESNOWFLAKE_ROLE (optional)Note: For Snowflake, the entrypoint automatically creates a clone database and sets SNOWFLAKE_DATABASE. The clone is destroyed when the task completes.
You must configure dbt to connect to the database:
profiles.yml in the dbt project directory with profile name retail_dw_masterDBT_PROFILES_DIR environment variable to the directory containing profiles.ymlConfigure with type: duckdb and the database path from $DUCKDB_PATH.
Configure with type: snowflake using password authentication:
schema: to $SNOWFLAKE_SCHEMA — do NOT leave it blank. A blank or omitted schema makes Snowflake silently default to PUBLIC, so your models get built in the wrong schema and the verifier cannot find them.Find and fix the dim_customers model in the mart layer. Investigate the data lineage and compare the model output against upstream sources. Fix all issues you find.
{% if target.type == 'snowflake' %}) where syntax differs between backends. Important: Boolean columns like is_cancelled may be stored differently across backends. DuckDB uses native booleans, but Snowflake may store them as VARCHAR. Use Jinja conditionals to handle this difference -- don't assume = false works everywhere.