Build a dbt project that analyzes inventory levels by warehouse with derived metrics
harbor run -t snowflake-labs/dbt-inventory-analysisharbor download snowflake-labs/dbt-inventory-analysisBuild a dbt project that produces a warehouse-level inventory summary with quantities, values, and cost metrics.
This 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. Reference dbt projects exist at /app/dbt_models_duckdb/ and /app/dbt_models_snowflake/ for inspection only. Write your dbt project at /app/dbt_project — outputs in the reference directories are not graded.
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 dbt_projectDBT_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:
The warehouse contains inventory and warehouse reference data in the INVENTORY schema. Explore the available tables to discover relevant columns for quantities, costs, and warehouse attributes. You will need to understand what columns are available and how the tables relate to each other before writing your models.
Only include records where the on-hand quantity is greater than zero.
Create a dbt project with staging and marts layers.
/app/dbt_project/app/dbt_projectinventory_analyticsCreate staging models that clean and standardize the source data:
Create fct_warehouse_inventory.sql that produces a warehouse-level inventory summary. For each warehouse, compute:
avg_unit_cost): the inventory-value-weighted average cost per unit. This is NOT a simple arithmetic average of unit costs -- it must account for the fact that a product with 1000 units matters more than one with 2 units. Specifically: total inventory value divided by total quantity.Round all monetary values to 2 decimal places. Materialize as a table.