Skip to main content

dbt Tools

6 tools for dbt intelligence and model verification (3 + 3).


dbt Intelligence

generate_sql_skeleton

Generate a SQL template from a YML column spec and referenced tables.

Parameters:

ParameterTypeRequiredDescription
connectionstringYesConnection name
projectstringYesdbt project name
modelstringYesModel name to generate skeleton for

Returns: SQL template with CTEs for each declared column in the YML. Column aliases are pre-populated to match YML exactly (case-sensitive).

When to use: Step 4 of the dbt-workflow skill — get the initial SQL structure before filling in logic.


dbt_error_parser

Parse raw dbt error output into structured diagnosis and fix suggestion.

Parameters:

ParameterTypeRequiredDescription
error_textstringYesRaw text from dbt run or dbt parse stderr
projectstringNodbt project name for context

Returns: Error type (e.g. duplicate_patch, ref_not_found, compilation_error), affected model, structured fix suggestion.

Error types handled:

  • duplicate_patch — same model patched in multiple YML files
  • ref_not_foundref() to a non-existent model
  • compilation_error — SQL syntax error in a model file
  • passthrough_warning — model returns all columns (SELECT *)
  • current_date_hazardcurrent_date/now() in a date-spine model
  • zero_rows — model builds but returns 0 rows

analyze_grain

Cardinality analysis: per-key distinct counts and fan-out factors.

Parameters:

ParameterTypeRequiredDescription
connectionstringYesConnection name
tablestringYesTable to analyze (usually a freshly built dbt model)
grain_keysarrayYesColumns that define the expected grain

Returns: Per-key distinct count, rows per key (mean/max), fan-out factor. Fan-out > 1.0 means the grain is violated.

When to use: When verifying that a model has the expected grain (e.g. one row per order_id).


Model Verification

check_model_schema

Compare materialized columns against YML-declared columns.

Parameters:

ParameterTypeRequiredDescription
connectionstringYesConnection name
projectstringYesdbt project name
modelstringYesModel name

Returns: Column alignment: columns present in DB but not in YML (extra), columns in YML but not in DB (missing), type mismatches.

When to use: After dbt run — verify the materialized table matches the YML contract.


validate_model_output

Row count validation, fan-out detection, and empty model detection.

Parameters:

ParameterTypeRequiredDescription
connectionstringYesConnection name
tablestringYesMaterialized table to validate
expected_min_rowsintegerNoMinimum expected row count (default: 1)
fan_out_thresholdnumberNoMax acceptable fan-out ratio (default: 1.5)

Returns: Row count, empty model flag, fan-out ratio per key column, pass/fail per check.


audit_model_sources

Upstream audit: source row counts, fan-out/over-filter ratios, and NULL scan.

Parameters:

ParameterTypeRequiredDescription
connectionstringYesConnection name
projectstringYesdbt project name
modelstringYesModel to audit sources for

Returns: Per-source table: row count, fan-out ratio (rows in model / rows in source), over-filter ratio, NULL count on key columns.

When to use: When validate_model_output shows unexpected row counts — trace back to which source is responsible.