Metacenta

Documentation · rule model-no-column-schema

dbt models that declare no columns

A Metacenta review checks this under the rule Models declare their columns. Everything below applies whether or not you ever commission one.

What this rule checks

This rule flags dbt models whose schema YAML lists no columns at all. A model that declares even one column passes here, and the column rules take it from there.

Why it matters

A declared column list is what every column description, column test and contract hangs off. Without one there is nothing to check a schema change against, so a renamed or dropped column goes unnoticed.

How to fix it

Declare column schemas for the models that have none. Declare the model's columns in its schema YAML. The dbt-codegen package can generate the stub from the built model, so you only fill in descriptions and tests.

Before:

models:
  - name: dim_customers
    description: One row per customer.

After:

models:
  - name: dim_customers
    description: One row per customer.
    columns:
      - name: customer_id
      - name: first_order_at
      - name: lifetime_value

When it is fine to leave

A short-lived or scratch model that nothing else reads. For everything else the stub costs a minute to generate.

What we need to check it

manifest.json. If no model or source in the manifest carries a columns object at all, we cannot tell a missing schema from a manifest built without one. The rule then says it could not assess, rather than flagging every model.