Skip to main content

Code Style Guide

Data Models

We generally follow the dbt style guides for mart and field names, even in sqlmesh. We recommend reading through these official style guides first:

Optionally, there is an excellent blog piece on best practices in naming for your stakeholders

In addition to the official guides, we follow these additional guidelines:

  • Use consistent naming: Ensure consistent naming in all int tables. For example if we use artifact_namespace, do not rename this to source, network, domain, or chain somewhere else.

  • Avoid complex marts: Push all complexity to intermediate tables. Marts should simply be a direct copy or less granular version of an intermediate table. View models are also a relatively cheap way to separate out complex CTEs.

  • Enumerate all columns explicitly in models: concretely, this mean

    • Avoid using * statements in a mart model. This makes it easier to trace any changes through version control.
    • Avoid using positional arguments (i.e. GROUP BY 1, 2, 3). This can lead to easy bugs if columns get re-ordered
    • Avoid using acronyms or single-letter names. Prioritize easy-to-understand names over speed.