Skip to main content

Inventory Statistics

Computes per-partition inventory KPIs — current inventory count, rolling sales counts, days-supply, and (optionally) average days-on-lot — grouped by configurable dimensions like dealer, neighborhood, country, or carline.

The component is a pure aggregation engine over consolidated inventory: it does no date arithmetic of its own, but applies a configurable rolling window over the sold_date_column computed by ConsolidatedComponent's derived_fields. One Dagster asset is emitted per grouping, partitioned by day.

Inputs​

  • Inventory — always <oem>/<market>/consolidated/inventory; not configurable. Must carry is_active — every KPI is scoped to on-lot vehicles, so the component raises on a frame missing it rather than counting sold vehicles as inventory.

  • joins — Reference tables left-joined onto inventory before aggregation, exposing the dimension columns referenced by group_by (e.g. dealer → country, model → carline).

  • sold_date_column — Column used for the rolling sales window. May be all-null for OEMs without a sold-date signal — the window then matches no rows, so inferred_sales_count_{n}D and days_supply_{n}D are null.

  • days_on_lot_column — Optional. When set, every grouping also emits avg_days_on_lot_{n}D per window.

  • windows — Rolling window sizes in days (default [90]).

  • exclude_custom_orders — Optional, default false. When true, the component computes every KPI from stock vehicles only. A stock vehicle is a vehicle whose is_custom_order is false or null. A custom order then counts neither as a sale nor as inventory, including while it is on the dealer's lot waiting for the customer to take delivery. A group whose vehicles are all custom orders has no output row.

    Volume optimization sets the quantities of stock orders. A dealer places a custom order when a customer orders a vehicle, in addition to the dealer's stock orders. A custom-order sale therefore does not reduce the dealer's stock. A custom order on the lot is not stock the dealer can sell.

  • excluded_sale_types — Optional, default []. A list of SaleType values. The following KPIs leave out the sold vehicles whose sale_type is in the list:

    • inferred_sales_count_{n}D
    • days_supply_{n}D
    • avail_adj_days_supply_{n}D
    • avg_days_on_lot_{n}D

    current_inventory_count and available_days_{n}D still count such a vehicle while it is on the lot.

Groupings​

Each grouping defines the GROUP BY dimensions for one output asset:

type: ai_dagster.components.InventoryStatisticsComponent
attributes:
oem: mb
name: inventory_statistics
start_date: "2025-01-01"
sold_date_column: inferred_sold_date
days_on_lot_column: days_on_lot
windows: [90]
joins:
- asset: mb/consolidated/dealers
join_on: [dealer_id]
fields: [country]
- asset: mb/dealers/neighborhoods
join_on: [dealer_id]
fields: [neighborhood]
- asset: mb/consolidated/models
join_on: [model_id]
fields: [carline_id]
groupings:
- key: dealer_neighborhood
group_by: [dealer_id, neighborhood]
- key: country
group_by: [country]
- key: carline
group_by: [carline_id]
- key: dealer_model
group_by: [dealer_id, model_id]
FieldDescription
keyLeaf segment of the asset key. Written to <oem>/inventory_stats/<key>
group_byColumns to aggregate by. Must be present on the joined frame
avail_adj_days_supplyOptional. Adds available_days_{n}D and avail_adj_days_supply_{n}D for each n in its windows, which must be component windows. max_days caps the days-supply value

Output columns​

Each grouping asset contains the group_by columns followed by:

ColumnDescription
current_inventory_countCount of rows where is_active is true
inferred_sales_count_{n}DRows with sold_date_column in [partition_date − n, partition_date)
days_supply_{n}Dcurrent_inventory_count / (inferred_sales_count_{n}D / n) — null when no sales fall in the window
available_days_{n}DDates in [partition_date − n, partition_date) on which the group had at least one vehicle on lot (only for groupings and windows that set avail_adj_days_supply)
avail_adj_days_supply_{n}Dcurrent_inventory_count / (inferred_sales_count_{n}D / available_days_{n}D), capped at avail_adj_days_supply.max_days. Counting only available days gives the sales rate of a group that had stock for part of the window. Null when no sales fall in the window
avg_days_on_lot_{n}DMean days_on_lot_column across the same sold-window (only when days_on_lot_column is set)

{n} substitutes each entry from windows.

Downstream consumers​

The grouping assets feed two parts of the derived graph:

  • Days on Lot — Joined onto each vehicle as features for both training and inference. Configurable per stats input via stats_inputs.
  • Take Rates — inventory_stats/country is implicitly joined onto every featurized vehicle so attribute aggregations have country-scope context.