Skip to content

Commit 90b5a08

Browse files
authored
Edits to documentation (#601)
* Remove bash syntax highlighting for CLI * Reorder guides and add integrations engine page to mkdocs.yml * Fix links in concepts/overview and quick_start * Edit guides/connections * Edit guides/scheduling * Edit guides/models * Edit integrations/github * minor edits to reference/ docs
1 parent 11887fa commit 90b5a08

13 files changed

Lines changed: 141 additions & 133 deletions

File tree

docs/concepts/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ In contrast to tests, SQLMesh "audits" validate the results of model code applie
5959

6060
You create audits by writing SQL queries that should return 0 rows. For example, an audit query to ensure `your_field` has no `NULL` values would include `WHERE your_field IS NULL`. If any NULLs are detected, the query will return at least one row and the audit will fail.
6161

62-
Audits are flexible - they can be tied to a specific model's contents, or you can use [macros](concepts/macros.md) to create audits usable by multiple models. SQLMesh also includes pre-made audits for common use cases like detecting NULL or duplicated values.
62+
Audits are flexible - they can be tied to a specific model's contents, or you can use [macros](macros.md) to create audits usable by multiple models. SQLMesh also includes pre-made audits for common use cases like detecting NULL or duplicated values.
6363

6464
You specify which audits should run for a model by including them in the model's metadata properties.
6565

docs/guides/connections.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@
44

55
**Note:** The following guide only applies when using the built-in scheduler. Connections are configured differently when using an external scheduler like Airflow. See the [Scheduling guide](scheduling.md) for more details.
66

7-
In order to deploy models and apply changes to them, a connection to the Data Warehouse must first be configured. This can be done through the `config.yaml` file in your project folder or in the `~/.sqlmesh` one.
7+
In order to deploy models and apply changes to them, you must configure a connection to the Data Warehouse. This can be done in either the `config.yaml` file in your project folder or the one in `~/.sqlmesh`.
88

9-
Each configured connection has a unique name associated with it, which can be used to select a specific connection when using CLI. For example:
9+
Each configured connection has a unique name associated with it, which can be used to select a specific connection when using the CLI. For example:
1010
```yaml linenums="1"
1111
connections:
1212
local_db:
1313
type: duckdb
1414
```
1515
16-
Now the defined connection can be specified in CLI as follows:
16+
Now the defined connection can be specified in the `sqlmesh plan` CLI command as follows:
1717
```bash
1818
sqlmesh --connection local_db plan
1919
```
2020

2121
## Default connection
22-
If no connection name is provided, then the first connection in the order of how connections are defined in the configuration will be picked.
22+
If no connection name is provided, then the first connection in the `config.yaml` connections specification will be used.
2323

24-
Additionally the default connection can be set in the configuration:
24+
Additionally, you can set a default connection by specifying the connection name in the `default_connection` key:
2525
```yaml linenums="1"
2626
default_connection: local_db
2727
```
2828

2929
## Test connection
30-
By default, when running [tests](../concepts/tests.md) SQLMesh uses an in-memory DuckDB database connection. This behavior can be overridden in the configuration:
30+
By default, when running [tests](../concepts/tests.md) SQLMesh uses an in-memory DuckDB database connection. You can override this behavior by specifying a connection name in the `test_connection` key:
3131
```yaml linenums="1"
3232
test_connection: local_db
3333
```
34-
Or in CLI:
34+
Or you can specify the test connection in the `sqlmesh plan` CLI command:
3535
```bash
3636
sqlmesh --test-connection local_db plan
3737
```
@@ -41,11 +41,11 @@ sqlmesh --test-connection local_db plan
4141
### BigQuery
4242
TBD
4343

44-
See the [configuration reference](../reference/configuration.md#bigquery) for more details.
44+
See the [engine configuration reference](../integrations/engines.md#bigquery---localbuilt-in-scheduler) for more details.
4545

4646
### Databricks
4747

48-
The Databricks configuration should be configured as follows:
48+
A Databricks connection should be configured as follows:
4949
```yaml linenums="1"
5050
connections:
5151
my_databricks_connection:
@@ -57,23 +57,23 @@ connections:
5757
concurrent_tasks: [optional, should be greater than 0]
5858
```
5959

60-
See the [configuration reference](../reference/configuration.md#databricks) for more details.
60+
See the [engine configuration reference](../integrations/engines.md#databricks---localbuilt-in-scheduler) for more details.
6161

6262
### DuckDB
6363

64-
The DuckDB configuration should be configured as follows:
64+
A DuckDB connection should be configured as follows:
6565
```yaml linenums="1"
6666
connections:
6767
my_duckdb_connection:
6868
type: duckdb
6969
database: [optional, path to the database file]
7070
```
7171

72-
See the [configuration reference](../reference/configuration.md#duckdb) for more details.
72+
See the [engine configuration reference](../reference/configuration.md#duckdb) for more details.
7373

7474
### Redshift
7575

76-
The Redshift configuration should be configured as follows:
76+
A Redshift connection should be configured as follows:
7777
```yaml linenums="1"
7878
connections:
7979
my_redshift_connection:
@@ -100,11 +100,11 @@ connections:
100100
concurrent_tasks: [optional, should be greater than 0]
101101
```
102102

103-
See the [configuration reference](../reference/configuration.md#redshift) for more details.
103+
See the [engine configuration reference](../integrations/engines.md#redshift---localbuilt-in-scheduler) for more details.
104104

105105
### Snowflake
106106

107-
The Databricks configuration should be configured as follows:
107+
A Snowflake connection should be configured as follows:
108108
```yaml linenums="1"
109109
connections:
110110
my_snowflake_connection:
@@ -118,4 +118,4 @@ connections:
118118
concurrent_tasks: [optional, should be greater than 0]
119119
```
120120

121-
See the [configuration reference](../reference/configuration.md#snowflake) for more details.
121+
See the [engine configuration reference](../integrations/engines.md#snowflake---localbuilt-in-scheduler) for more details.

docs/guides/models.md

Lines changed: 86 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Before adding a model, ensure that you have [already created your project](/guid
1212

1313
To add a model:
1414

15-
1. Within your `models` folder, create a new database file. For example, `example_new_model.sql`.
15+
1. Within your `models` folder, create a new file. For example, `example_new_model.sql`.
1616
2. Within the file, define your model as follows:
1717

1818
MODEL (
@@ -33,12 +33,12 @@ To add a model:
3333
To edit an existing model:
3434

3535
1. Open the model file you wish to edit in your preferred editor and make a change.
36-
2. To preview an example of what your change looks like without actually creating a table, use the `evaluate` command. Refer to [evaluating a model](#evaluating-a-model).
37-
3. To materialize this change, use the `plan` command. Refer to [previewing changes using the `plan` command](#previewing-changes-using-the-plan-command).
36+
2. To preview an example of what your change looks like without actually creating a table, use the `sqlmesh evaluate` command. Refer to [evaluating a model](#evaluating-a-model).
37+
3. To materialize this change, use the `sqlmesh plan` command. Refer to [previewing changes using the `plan` command](#previewing-changes-using-the-plan-command).
3838

3939
### Evaluating a model
4040

41-
The `evaluate` command will run a query against your database or engine and return a DataFrame. It is used to test or iterate on models without side effects, and since SQLMesh isn't materializing any data, with minimal cost.
41+
The `evaluate` command will run a query against your database or engine and return a dataframe. It is used to test or iterate on models without database side effects and at minimal cost because SQLMesh isn't materializing any data.
4242

4343
To evaluate a model:
4444

@@ -49,7 +49,7 @@ To evaluate a model:
4949
id item_id ds
5050
0 7 1 2020-01-07
5151

52-
2. Once the `evaluate` command detects the changes made to your model, observe that the output from your new model is shown.
52+
2. When you run the `evaluate` command, SQLMesh detects the changes made to the model, executes the model as a query using the options passed to `evaluate`, and shows the output returned by the model query.
5353

5454
### Previewing changes using the `plan` command
5555

@@ -58,123 +58,126 @@ When SQLMesh runs the `plan` command on your environment, it will show you wheth
5858
To preview changes using `plan`:
5959

6060
1. Enter the `sqlmesh plan <environment name>` command.
61-
2. Enter `1` to classify the changes as `Breaking`, or enter `2` to classify the changes as `Non-Breaking`:
62-
63-
$ sqlmesh plan dev
64-
======================================================================
65-
Successfully Ran 1 tests against duckdb
66-
----------------------------------------------------------------------
67-
Summary of differences against `dev`:
68-
├── Directly Modified:
69-
│ └── sqlmesh_example.example_incremental_model
70-
└── Indirectly Modified:
71-
└── sqlmesh_example.example_full_model
72-
---
73-
+++
74-
@@ -1,6 +1,7 @@
75-
SELECT
76-
id,
77-
item_id,
78-
+ 1 AS new_column,
79-
ds
80-
FROM (VALUES
81-
(1, 1, '2020-01-01'),
82-
Directly Modified: sqlmesh_example.example_incremental_model
83-
└── Indirectly Modified Children:
84-
└── sqlmesh_example.example_full_model
85-
[1] [Breaking] Backfill sqlmesh_example.example_incremental_model and indirectly modified children
86-
[2] [Non-breaking] Backfill sqlmesh_example.example_incremental_model but not indirectly modified children: 2
87-
Models needing backfill (missing dates):
88-
└── sqlmesh_example.example_incremental_model: (2020-01-01, 2023-02-17)
89-
Enter the backfill start date (eg. '1 year', '2020-01-01') or blank for the beginning of history:
90-
Enter the backfill end date (eg. '1 month ago', '2020-01-01') or blank to backfill up until now:
91-
Apply - Backfill Tables [y/n]: y
92-
93-
All model batches have been executed successfully
94-
95-
sqlmesh_example.example_incremental_model ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 1/1 • 0:00:00
61+
2. Enter `1` to classify the changes as `Breaking`, or enter `2` to classify the changes as `Non-Breaking`. In this example, the changes are classified as `Non-Breaking`:
62+
63+
```hl_lines="23 24"
64+
$ sqlmesh plan dev
65+
======================================================================
66+
Successfully Ran 1 tests against duckdb
67+
----------------------------------------------------------------------
68+
Summary of differences against `dev`:
69+
├── Directly Modified:
70+
│ └── sqlmesh_example.example_incremental_model
71+
└── Indirectly Modified:
72+
└── sqlmesh_example.example_full_model
73+
---
74+
+++
75+
@@ -1,6 +1,7 @@
76+
SELECT
77+
id,
78+
item_id,
79+
+ 1 AS new_column,
80+
ds
81+
FROM (VALUES
82+
(1, 1, '2020-01-01'),
83+
Directly Modified: sqlmesh_example.example_incremental_model
84+
└── Indirectly Modified Children:
85+
└── sqlmesh_example.example_full_model
86+
[1] [Breaking] Backfill sqlmesh_example.example_incremental_model and indirectly modified children
87+
[2] [Non-breaking] Backfill sqlmesh_example.example_incremental_model but not indirectly modified children: 2
88+
Models needing backfill (missing dates):
89+
└── sqlmesh_example.example_incremental_model: (2020-01-01, 2023-02-17)
90+
Enter the backfill start date (eg. '1 year', '2020-01-01') or blank for the beginning of history:
91+
Enter the backfill end date (eg. '1 month ago', '2020-01-01') or blank to backfill up until now:
92+
Apply - Backfill Tables [y/n]: y
93+
94+
All model batches have been executed successfully
95+
96+
sqlmesh_example.example_incremental_model ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 1/1 • 0:00:00
97+
```
9698

9799
For more information, refer to [plans](../concepts/plans.md).
98100

99101
## Reverting a change to a model
100102

101103
---
102104

103-
Before reverting a change, ensure that you have already made a change and that you have run the `sqlmesh plan` command.
105+
Before trying to revert a change, ensure that you have already made a change and that you have run the `sqlmesh plan` command.
104106

105107
---
106108

107109
To revert your change:
108110

109-
1. Open the model file you wish to edit in your preferred editor, and undo a change you made earlier. For this example, we'll remove the column we added from the [quickstart](/quick_start).
111+
1. Open the model file you wish to edit in your preferred editor, and undo a change you made earlier. For this example, we'll remove the column we added in the [quickstart](../quick_start.md) example.
110112
2. Run `sqlmesh plan` and apply your changes. Enter `y` to run a Virtual Update.
111113

112-
$ sqlmesh plan dev
113-
======================================================================
114-
Successfully Ran 1 tests against duckdb
115-
----------------------------------------------------------------------
116-
Summary of differences against `dev`:
117-
├── Directly Modified:
118-
│ └── sqlmesh_example.example_incremental_model
119-
└── Indirectly Modified:
120-
└── sqlmesh_example.example_full_model
121-
---
122-
+++
123-
@@ -1,7 +1,6 @@
124-
125-
SELECT
126-
id,
127-
item_id,
128-
- 1 AS new_column,
129-
ds
130-
FROM (VALUES
131-
(1, 1, '2020-01-01'),
132-
Directly Modified: sqlmesh_example.example_incremental_model (Non-breaking)
133-
└── Indirectly Modified Children:
134-
└── sqlmesh_example.example_full_model
135-
Apply - Virtual Update [y/n]: y
136-
137-
Virtual Update executed successfully
138-
114+
```hl_lines="24"
115+
$ sqlmesh plan dev
116+
======================================================================
117+
Successfully Ran 1 tests against duckdb
118+
----------------------------------------------------------------------
119+
Summary of differences against `dev`:
120+
├── Directly Modified:
121+
│ └── sqlmesh_example.example_incremental_model
122+
└── Indirectly Modified:
123+
└── sqlmesh_example.example_full_model
124+
---
125+
+++
126+
@@ -1,7 +1,6 @@
127+
128+
SELECT
129+
id,
130+
item_id,
131+
- 1 AS new_column,
132+
ds
133+
FROM (VALUES
134+
(1, 1, '2020-01-01'),
135+
Directly Modified: sqlmesh_example.example_incremental_model (Non-breaking)
136+
└── Indirectly Modified Children:
137+
└── sqlmesh_example.example_full_model
138+
Apply - Virtual Update [y/n]: y
139+
140+
Virtual Update executed successfully
141+
```
139142
### Virtual Update
140143

141-
Reverting to a previous version is a quick operation as no additional work is being done. For more information, refer to [plan application](../concepts/plans.md#plan-application) and [Virtual Update](../concepts/plans.md#virtual-update).
144+
Reverting to a previous model version is a quick operation since no additional work is being done. For more information, refer to [plan application](../concepts/plans.md#plan-application) and [Virtual Update](../concepts/plans.md#virtual-update).
142145

143-
**Note:** The janitor runs periodically and automatically to clean up SQLMesh artifacts no longer being used, and determines the time-to-live (TTL) for tables (how much time can pass before reverting is no longer possible).
146+
**Note:** The SQLMesh janitor runs periodically and automatically to clean up SQLMesh artifacts no longer being used, and determines the time-to-live (TTL) for tables (how much time can pass before reverting is no longer possible).
144147

145148
## Validating changes to a model
146149

147150
### Automatic model validation
148151

149-
SQLMesh automatically validates your models in order to ensure the quality and accuracy of your data. This is done by the following:
152+
SQLMesh automatically validates your models in order to ensure the quality and accuracy of your data. This is done via the following:
150153

151-
* Running unit tests by default when you run the `plan` command. This ensures all changes to applied to any environment is logically validated. Refer to [testing](/concepts/tests) for more information.
152-
* Running audits whenever data is loaded to a table (both backfill and loading on a cadence). This way you know all data present in any table has passed defined audits. Refer to [auditing](/concepts/audits) for more information.
154+
* Running unit tests by default when you execute the `plan` command. This ensures all changes to applied to any environment are logically validated. Refer to [testing](../concepts/tests.md) for more information.
155+
* Running audits whenever data is loaded to a table (either for backfill or loading on a cadence). This way you know all data present in any table has passed all defined audits. Refer to [auditing](../concepts/audits.md) for more information.
153156

154-
CI/CD is another way SQLMesh provides automatic validation, since the preview environment is automatically created.
157+
SQLMesh also provides automatic validation via CI/CD by automatically creating a preview environment.
155158

156159
### Manual model validation
157160

158161
To manually validate your models, you can perform one or more of the following tasks:
159162

160163
* [Evaluating a model](#evaluating-a-model)
161-
* [Testing a model using unit tests](/guides/testing#testing-changes-to-models)
162-
* [Auditing a model](/guides/testing#auditing-changes-to-models)
164+
* [Testing a model using unit tests](../guides/testing.md#auditing-changes-to-models)
165+
* [Auditing a model](../guides/testing.md#auditing-changes-to-models)
163166
* [Previewing changes using the `plan` command](#previewing-changes-using-the-plan-command)
164167

165168
## Viewing the DAG
166169

167170
---
168171

169-
Before generating the DAG, ensure that you have already installed the graphviz package.
172+
Before generating a DAG, ensure that you have already installed the graphviz package.
170173

171-
To install the graphviz package, enter the following command:
174+
To install the package with `pip`, enter the following command:
172175

173176
```bash
174177
pip install graphviz
175178
```
176179

177-
Alternatively, enter the following command:
180+
Alternatively, enter the following command to install graphviz with `apt-get`:
178181

179182
```bash
180183
sudo apt-get install graphviz
@@ -198,8 +201,8 @@ Before deleting a model, ensure that you have already run `sqlmesh plan`.
198201

199202
To delete a model:
200203

201-
1. Within your `models` folder, delete the file containing the model you wish to remove. For this example, we'll delete the `example_full_model.sql` file from our [quickstart](/quick_start) project.
202-
2. Run the `sqlmesh plan <environment>` command, and enter the environment to which you want to apply the change. In the following example, we apply the change to our development environment:
204+
1. Within your `models` folder, delete the file containing the model you wish to remove. For this example, we'll delete the `example_full_model.sql` file from our [quickstart](../quick_start.md) project.
205+
2. Run the `sqlmesh plan <environment>` command, specifying the environment to which you want to apply the change. In the following example, we apply the change to our development environment `dev`:
203206

204207
```
205208
$ sqlmesh plan dev
@@ -220,7 +223,7 @@ To delete a model:
220223
sqlmesh_example.example_incremental_model ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 1/1 • 0:00:00
221224
```
222225

223-
**Note:** If you have other files that reference the model you wish to delete, an error message will note the file(s) containing the reference. You will need to also delete these files in order for the change to be applied.
226+
**Note:** If you have other files that reference the model you wish to delete, an error message will note the file(s) containing the reference. You will need to also delete these files in order to apply the change.
224227

225228
3. Plan and apply your changes to production, and enter `y` for the Virtual Update. By default, the `sqlmesh plan` command targets your production environment:
226229

0 commit comments

Comments
 (0)