Skip to content

Generic

columns_have_description

All columns of a model should have a description.

Source code
@rule
def columns_have_description(model: Model) -> RuleViolation | None:
    """All columns of a model should have a description."""
    invalid_column_names = [
        column.name for column in model.columns if not column.description
    ]
    if invalid_column_names:
        max_length = 60
        message = f"Columns lack a description: {', '.join(invalid_column_names)}."
        if len(message) > max_length:
            message = f"{message[:60]}…"
        return RuleViolation(message=message)

Default configuration

pyproject.toml
[tool.dbt-score.rules."dbt_score.rules.generic.columns_have_description"]
severity = 2

has_description

A model should have a description.

Source code
@rule
def has_description(model: Model) -> RuleViolation | None:
    """A model should have a description."""
    if not model.description:
        return RuleViolation(message="Model lacks a description.")

Default configuration

pyproject.toml
[tool.dbt-score.rules."dbt_score.rules.generic.has_description"]
severity = 2

has_example_sql

The documentation of a model should have an example query.

Source code
@rule(severity=Severity.LOW)
def has_example_sql(model: Model) -> RuleViolation | None:
    """The documentation of a model should have an example query."""
    if model.language == "sql":
        if "```sql" not in model.description:
            return RuleViolation(
                "The model description does not include an example SQL query."
            )

Default configuration

pyproject.toml
[tool.dbt-score.rules."dbt_score.rules.generic.has_example_sql"]
severity = 1

has_owner

A model should have an owner.

Source code
@rule
def has_owner(model: Model) -> RuleViolation | None:
    """A model should have an owner."""
    if not model.meta.get("owner"):
        return RuleViolation(message="Model lacks an owner.")

Default configuration

pyproject.toml
[tool.dbt-score.rules."dbt_score.rules.generic.has_owner"]
severity = 2

sql_has_reasonable_number_of_lines

The SQL query of a model should not be too long.

Source code
@rule
def sql_has_reasonable_number_of_lines(
    model: Model, max_lines: int = 200
) -> RuleViolation | None:
    """The SQL query of a model should not be too long."""
    count_lines = len(model.raw_code.split("\n"))
    if count_lines > max_lines:
        return RuleViolation(
            message=f"SQL query too long: {count_lines} lines (> {max_lines})."
        )

Default configuration

pyproject.toml
[tool.dbt-score.rules."dbt_score.rules.generic.sql_has_reasonable_number_of_lines"]
severity = 2
max_lines = 200