Skip to content

feat: dbts cost — standalone QUERY_HISTORY cost command #14

Description

@luiul

Summary

Promote the `--cost` logic currently embedded in `dbts plan` to a standalone `dbts cost` command for ad-hoc QUERY_HISTORY exploration without needing a build set.

Why

`dbts plan --cost` is great for "what would this build cost?", but doesn't help with "what's the most expensive model in the project right now?" or "show me the top 10 cost queries this week" — both of which currently require writing custom SQL against `SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY`.

Sketch

  • `dbts cost [selectors...]` — like `plan --cost` but without the offline output.
  • `dbts cost --top 10` — top-N most expensive models in the lookback window, no selectors needed.
  • `dbts cost --tag ` — filter by an arbitrary query-tag dimension.
  • Reuse `--days N`, `--target`, `$DBTS_CREDIT_RATE` from the existing cost pathway.

Where it'd live

  • Promote logic from `src/dbts/plan.py` (cost portion) to a shared module `src/dbts/cost.py`.
  • New CLI command `cmd_cost` under PANEL_INSPECT.
  • Existing `plan --cost` becomes a thin caller.

Effort

Small–medium. Most logic exists; the work is mostly factoring.

Tier

Tier 2 — lesser idea (modest value over the existing `plan --cost`).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions