Skip to content

Commit 5dfbff3

Browse files
authored
add guidance to using underscores or dots for dbt model naming (#4750)
this pr adds explicit guidance on how to name dbt models. it adds : - we recommend using underscores and not dots - dots are supported, however come with complexity. - adds guidance to models doc, style doc, and links to style doc. this stemmed from user confusion and [slack thread](https://dbt-labs.slack.com/archives/C012TTNN0JK/p1705660484585649?thread_ts=1704991223.136339&cid=C012TTNN0JK)
2 parents 0b26ef4 + 87dae9f commit 5dfbff3

File tree

4 files changed

+32
-33
lines changed

4 files changed

+32
-33
lines changed

website/docs/best-practices/how-we-style/1-how-we-style-our-dbt-models.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ id: 1-how-we-style-our-dbt-models
88
- 👥 Models should be pluralized, for example, `customers`, `orders`, `products`.
99
- 🔑 Each model should have a primary key.
1010
- 🔑 The primary key of a model should be named `<object>_id`, for example, `account_id`. This makes it easier to know what `id` is being referenced in downstream joined models.
11+
- Use underscores for naming dbt models; avoid dots.
12+
-`models_without_dots`
13+
-`models.with.dots`
14+
- Most data platforms use dots to separate `database.schema.object`, so using underscores instead of dots reduces your need for [quoting](/reference/resource-properties/quoting) as well as the risk of issues in certain parts of dbt Cloud. For more background, refer to [this GitHub issue](https://github.com/dbt-labs/dbt-core/issues/3246).
1115
- 🔑 Keys should be string data types.
1216
- 🔑 Consistency is key! Use the same field names across models where possible. For example, a key to the `customers` table should be named `customer_id` rather than `user_id` or 'id'.
1317
- ❌ Do not use abbreviations or aliases. Emphasize readability over brevity. For example, do not use `cust` for `customer` or `o` for `orders`.

website/docs/docs/build/models.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pagination_next: "docs/build/sql-models"
66
pagination_prev: null
77
---
88

9-
## Overview
10-
119
dbt Core and Cloud are composed of different moving parts working harmoniously. All of them are important to what dbt does — transforming data—the 'T' in ELT. When you execute `dbt run`, you are running a model that will transform your data without that data ever leaving your warehouse.
1210

1311
Models are where your developers spend most of their time within a dbt environment. Models are primarily written as a `select` statement and saved as a `.sql` file. While the definition is straightforward, the complexity of the execution will vary from environment to environment. Models will be written and rewritten as needs evolve and your organization finds new ways to maximize efficiency.

website/docs/docs/build/sql-models.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ dbt's Python capabilities are an extension of its capabilities with SQL models.
2929
A SQL model is a `select` statement. Models are defined in `.sql` files (typically in your `models` directory):
3030
- Each `.sql` file contains one model / `select` statement
3131
- The model name is inherited from the filename.
32-
- Models can be nested in subdirectories within the `models` directory
32+
- We strongly recommend using underscores for model names, not dots. For example, use `models/my_model.sql` instead of `models/my.model.sql`.
33+
- Models can be nested in subdirectories within the `models` directory.
34+
35+
Refer to [How we style our dbt models](/best-practices/how-we-style/1-how-we-style-our-dbt-models) for details on how we recommend you name your models.
3336

3437
When you execute the [`dbt run` command](/reference/commands/run), dbt will build this model <Term id="data-warehouse" /> by wrapping it in a `create view as` or `create table as` statement.
3538

website/docs/docs/cloud/dbt-cloud-ide/develop-in-the-cloud.md

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -133,38 +133,32 @@ The dbt Cloud IDE makes it possible to [build and view](/docs/collaborate/build-
133133

134134
## Related docs
135135

136-
- [dbt Cloud features](/docs/cloud/about-cloud/dbt-cloud-features)
137-
- [IDE user interface](/docs/cloud/dbt-cloud-ide/ide-user-interface)
136+
- [How we style our dbt projects](/best-practices/how-we-style/0-how-we-style-our-dbt-projects)
137+
- [User interface](/docs/cloud/dbt-cloud-ide/ide-user-interface)
138138
- [Version control basics](/docs/collaborate/git/version-control-basics)
139139
- [dbt Commands](/reference/dbt-commands)
140-
- [dbt Cloud IDE release notes](/tags/ide)
141140

142141
## Related questions
143142

144-
<FAQ path="Git/gitignore"/> <br />
145-
146-
<details>
147-
<summary>Is there a cost to using the Cloud IDE?</summary>
148-
<div>
149-
<div>Not at all! You can use dbt Cloud when you sign up for the <a href="https://www.getdbt.com/pricing/">Free Developer plan</a>, which comes with one developer seat. If you’d like to access more features or have more developer seats, you can upgrade your account to the Team or Enterprise plan. See <a href="https://www.getdbt.com/pricing/">dbt pricing plans</a> for more details. </div>
150-
</div>
151-
</details>
152-
<details>
153-
<summary>Can I be a contributor to dbt Cloud?</summary>
154-
<div>
155-
<div>Anyone can contribute to the dbt project. And whether it's a dbt package, a plugin, dbt-core, or this documentation site, contributing to the open-source code that supports the dbt ecosystem is a great way to level yourself up as a developer, and give back to the community. See <a href="https://docs.getdbt.com/community/resources/oss-expectations">Contributing</a> for details on what to expect when contributing to the dbt open source software (OSS). </div>
156-
</div>
157-
</details>
158-
<details>
159-
<summary>What is the difference between developing on the dbt Cloud IDE, the dbt Cloud CLI, and dbt Core?</summary>
160-
<div>
161-
<div>You can develop dbt using the web-based IDE in dbt Cloud or on the command line interface using the dbt Cloud CLI or open-source dbt Core, all of which enable you to execute dbt commands. The key distinction between the dbt Cloud CLI and dbt Core is the dbt Cloud CLI is tailored for dbt Cloud's infrastructure and integrates with all its features.<br /><br />
162-
<span>&mdash; </span>
163-
<b>dbt Cloud IDE:</b> <a href="https://docs.getdbt.com/docs/cloud/about-cloud/dbt-cloud-features">dbt Cloud</a> is a web-based application that allows you to develop dbt projects with the IDE, includes a purpose-built scheduler, and provides an easier way to share your dbt documentation with your team. The IDE is a faster and more reliable way to deploy your dbt models and provides a real-time editing and execution environment for your dbt project. <br /><br />
164-
<span>&mdash; </span>
165-
<b>dbt Cloud CLI: </b> <a href="https://docs.getdbt.com/docs/cloud/cloud-cli-installation">The dbt Cloud CLI</a> allows you to run dbt commands against your dbt Cloud development environment from your local command line or code editor. It supports cross-project ref, speedier, lower-cost builds, automatic deferral of build artifacts, and more. <br /><br />
166-
<span>&mdash; </span>
167-
<b>dbt Core:</b> dbt Core is an <a href="https://github.com/dbt-labs/dbt">open-sourced</a> software that’s freely available. You can build your dbt project in a code editor, and run dbt commands from the command line.
168-
</div>
169-
</div>
170-
</details>
143+
<FAQ path="Git/gitignore"/>
144+
145+
<detailsToggle alt_header="Is there a cost to using the Cloud IDE?">
146+
Not at all! You can use dbt Cloud when you sign up for the <a href="https://www.getdbt.com/pricing/">Free Developer plan</a>, which comes with one developer seat. If you’d like to access more features or have more developer seats, you can upgrade your account to the Team or Enterprise plan.<br />
147+
148+
Refer to <a href="https://www.getdbt.com/pricing/">dbt pricing plans</a> for more details.
149+
</detailsToggle>
150+
151+
<detailsToggle alt_header="Can I be a contributor to dbt Cloud?">
152+
As a proprietary product, dbt Cloud's source code isn't available for community contributions. If you want to build something in the dbt ecosystem, we encourage you to review [this article](/community/contributing/contributing-coding) about contributing to a dbt package, a plugin, dbt-core, or this documentation site. Participation in open-source is a great way to level yourself up as a developer, and give back to the community.
153+
</detailsToggle>
154+
155+
<detailsToggle alt_header="What is the difference between developing on the dbt Cloud IDE, the dbt Cloud CLI, and dbt Core?">
156+
You can develop dbt using the web-based IDE in dbt Cloud or on the command line interface using the dbt Cloud CLI or open-source dbt Core, all of which enable you to execute dbt commands. The key distinction between the dbt Cloud CLI and dbt Core is the dbt Cloud CLI is tailored for dbt Cloud's infrastructure and integrates with all its features:
157+
158+
- dbt Cloud IDE: <a href="https://docs.getdbt.com/docs/cloud/about-cloud/dbt-cloud-features">dbt Cloud</a> is a web-based application that allows you to develop dbt projects with the IDE, includes a purpose-built scheduler, and provides an easier way to share your dbt documentation with your team. The IDE is a faster and more reliable way to deploy your dbt models and provides a real-time editing and execution environment for your dbt project.
159+
160+
- dbt Cloud CLI: <a href="https://docs.getdbt.com/docs/cloud/cloud-cli-installation">The dbt Cloud CLI</a> allows you to run dbt commands against your dbt Cloud development environment from your local command line or code editor. It supports cross-project ref, speedier, lower-cost builds, automatic deferral of build artifacts, and more.
161+
162+
- dbt Core: dbt Core is an <a href="https://github.com/dbt-labs/dbt">open-sourced</a> software that’s freely available. You can build your dbt project in a code editor, and run dbt commands from the command line
163+
164+
</detailsToggle>

0 commit comments

Comments
 (0)