You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ In contrast to tests, SQLMesh "audits" validate the results of model code applie
59
59
60
60
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.
61
61
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.
63
63
64
64
You specify which audits should run for a model by including them in the model's metadata properties.
Copy file name to clipboardExpand all lines: docs/guides/connections.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,34 +4,34 @@
4
4
5
5
**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.
6
6
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`.
8
8
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:
10
10
```yaml linenums="1"
11
11
connections:
12
12
local_db:
13
13
type: duckdb
14
14
```
15
15
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:
17
17
```bash
18
18
sqlmesh --connection local_db plan
19
19
```
20
20
21
21
## 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.
23
23
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:
25
25
```yaml linenums="1"
26
26
default_connection: local_db
27
27
```
28
28
29
29
## 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:
31
31
```yaml linenums="1"
32
32
test_connection: local_db
33
33
```
34
-
Or in CLI:
34
+
Or you can specify the test connection in the `sqlmesh plan` CLI command:
35
35
```bash
36
36
sqlmesh --test-connection local_db plan
37
37
```
@@ -41,11 +41,11 @@ sqlmesh --test-connection local_db plan
41
41
### BigQuery
42
42
TBD
43
43
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.
45
45
46
46
### Databricks
47
47
48
-
The Databricks configuration should be configured as follows:
48
+
A Databricks connection should be configured as follows:
49
49
```yaml linenums="1"
50
50
connections:
51
51
my_databricks_connection:
@@ -57,23 +57,23 @@ connections:
57
57
concurrent_tasks: [optional, should be greater than 0]
58
58
```
59
59
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.
61
61
62
62
### DuckDB
63
63
64
-
The DuckDB configuration should be configured as follows:
64
+
A DuckDB connection should be configured as follows:
65
65
```yaml linenums="1"
66
66
connections:
67
67
my_duckdb_connection:
68
68
type: duckdb
69
69
database: [optional, path to the database file]
70
70
```
71
71
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.
73
73
74
74
### Redshift
75
75
76
-
The Redshift configuration should be configured as follows:
76
+
A Redshift connection should be configured as follows:
77
77
```yaml linenums="1"
78
78
connections:
79
79
my_redshift_connection:
@@ -100,11 +100,11 @@ connections:
100
100
concurrent_tasks: [optional, should be greater than 0]
101
101
```
102
102
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.
104
104
105
105
### Snowflake
106
106
107
-
The Databricks configuration should be configured as follows:
107
+
A Snowflake connection should be configured as follows:
108
108
```yaml linenums="1"
109
109
connections:
110
110
my_snowflake_connection:
@@ -118,4 +118,4 @@ connections:
118
118
concurrent_tasks: [optional, should be greater than 0]
119
119
```
120
120
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.
Copy file name to clipboardExpand all lines: docs/guides/models.md
+86-83Lines changed: 86 additions & 83 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Before adding a model, ensure that you have [already created your project](/guid
12
12
13
13
To add a model:
14
14
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`.
16
16
2. Within the file, define your model as follows:
17
17
18
18
MODEL (
@@ -33,12 +33,12 @@ To add a model:
33
33
To edit an existing model:
34
34
35
35
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).
38
38
39
39
### Evaluating a model
40
40
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.
42
42
43
43
To evaluate a model:
44
44
@@ -49,7 +49,7 @@ To evaluate a model:
49
49
id item_id ds
50
50
0 7 1 2020-01-07
51
51
52
-
2.Once the `evaluate` commanddetects 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.
53
53
54
54
### Previewing changes using the `plan` command
55
55
@@ -58,123 +58,126 @@ When SQLMesh runs the `plan` command on your environment, it will show you wheth
58
58
To preview changes using `plan`:
59
59
60
60
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`:
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`:
For more information, refer to [plans](../concepts/plans.md).
98
100
99
101
## Reverting a change to a model
100
102
101
103
---
102
104
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.
104
106
105
107
---
106
108
107
109
To revert your change:
108
110
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.
110
112
2. Run `sqlmesh plan` and apply your changes. Enter `y` to run a Virtual Update.
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).
142
145
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).
144
147
145
148
## Validating changes to a model
146
149
147
150
### Automatic model validation
148
151
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:
150
153
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.
153
156
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.
155
158
156
159
### Manual model validation
157
160
158
161
To manually validate your models, you can perform one or more of the following tasks:
159
162
160
163
*[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)
163
166
*[Previewing changes using the `plan` command](#previewing-changes-using-the-plan-command)
164
167
165
168
## Viewing the DAG
166
169
167
170
---
168
171
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.
170
173
171
-
To install the graphviz package, enter the following command:
174
+
To install the package with `pip`, enter the following command:
172
175
173
176
```bash
174
177
pip install graphviz
175
178
```
176
179
177
-
Alternatively, enter the following command:
180
+
Alternatively, enter the following command to install graphviz with `apt-get`:
178
181
179
182
```bash
180
183
sudo apt-get install graphviz
@@ -198,8 +201,8 @@ Before deleting a model, ensure that you have already run `sqlmesh plan`.
198
201
199
202
To delete a model:
200
203
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`:
**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.
224
227
225
228
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:
0 commit comments