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
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,9 @@ Bad data is worse than no data. The best way to keep bad data out of your system
52
52
### [Tests](./tests.md)
53
53
SQLMesh "tests" are similar to unit tests in software development, where the unit is a single model. SQLMesh tests validate model *code*— you specify the input data and expected output, then SQLMesh runs the test and compares the expected and actual output.
54
54
55
-
SQLMesh automatically runs tests when you apply a `plan`, or you can run them on demand with the [`test` command](../reference/cli.md#test).
55
+
SQLMesh automatically runs tests for models included in a `plan` (added, modified, or restated). Plans with no such models, and `--skip-backfill` / `--dry-run` plans, skip unit tests by default. Use `--all-tests` for the full suite, `--skip-tests` to skip, or run tests on demand with the [`test` command](../reference/cli.md#test).
56
+
57
+
Learn more in the [testing guide](../guides/testing.md).
56
58
57
59
### [Audits](./audits.md)
58
60
In contrast to tests, SQLMesh "audits" validate the results of model code applied to your actual data.
Copy file name to clipboardExpand all lines: docs/concepts/tests.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,12 @@
1
1
# Testing
2
2
3
-
Testing allows you to protect your project from regression by continuously verifying that the output of each model matches your expectations. Unlike [audits](audits.md), tests are executed either on demand (for example, as part of a CI/CD job) or every time a new [plan](plans.md) is created.
3
+
Testing allows you to protect your project from regression by continuously verifying that the output of each model matches your expectations. Unlike [audits](audits.md), tests are executed either on demand (for example, as part of a CI/CD job or via [`sqlmesh test`](../reference/cli.md#test)) or when a new [plan](plans.md) is created.
4
+
5
+
By default, `sqlmesh plan` runs unit tests only for models included in the plan (added, modified, or restated). Plans with no such models skip unit tests. Use `--all-tests` to run the full suite, or `--skip-tests` to run none.
6
+
7
+
!!! important
8
+
9
+
`--skip-backfill` / `--dry-run` plans skip unit tests by default. Pass `--all-tests` if you still want the full suite to run.
4
10
5
11
Similar to unit testing in software development, SQLMesh evaluates the model's logic against predefined inputs and then compares the output to expected outcomes provided as part of each test.
Copy file name to clipboardExpand all lines: docs/faq/faq.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@
66
66
67
67
However, the commands to create and apply a plan are different. In Terraform, the "plan" command generates a plan and saves it to file. The "apply" command reads a plan file and applies it.
68
68
69
-
In SQLMesh, the `sqlmesh plan` command generates a plan, runs any unit tests, and prompts the user to apply the plan. There is no "apply" command in SQLMesh.
69
+
In SQLMesh, the `sqlmesh plan` command generates a plan, runs unit tests for models included in the plan, and prompts the user to apply the plan. There is no "apply" command in SQLMesh.
70
70
71
71
## Getting Started
72
72
@@ -102,7 +102,7 @@
102
102
SQLMesh's default behavior is appropriate for most deployments, but you can override where SQLMesh creates physical tables and views with [schema configuration options](../guides/configuration.md#environment-schemas).
103
103
104
104
??? question "What's the difference between a `test` and an `audit`?"
105
-
A SQLMesh [`test`](../concepts/tests.md) is analogous to a "unit test" in software engineering. It tests *code* based on known inputs and outputs. In SQLMesh, the inputs and outputs are specified in a YAML file, and SQLMesh automatically runs them when `sqlmesh plan` is executed.
105
+
A SQLMesh [`test`](../concepts/tests.md) is analogous to a "unit test" in software engineering. It tests *code* based on known inputs and outputs. In SQLMesh, the inputs and outputs are specified in a YAML file, and SQLMesh runs tests for models included in the plan when `sqlmesh plan` is executed (use `--all-tests` for the full suite).
106
106
107
107
Writing YAML is annoying and error-prone, so SQLMesh's [`create_test` command](../concepts/tests.md#automatic-test-generation) allows you to automatically generate YAML test files based on queries of existing data tables.
108
108
@@ -126,7 +126,7 @@
126
126
??? question "What's the difference between `sqlmesh plan` and `sqlmesh run`?"
127
127
During project development, there are two things in play: the current state of your project files and the existing states of each environment you have.
128
128
129
-
SQLMesh’s `plan` command is the primary tool for understanding the effects of changes you make to your project. If your project files have changed or are different from the state of an environment, you execute `sqlmesh plan [environment name]` to synchronize the environment's state with your project files. `sqlmesh plan` will generate a summary of the actions needed to implement the changes, automatically run unit tests, and prompt you to `apply` the plan and implement the changes.
129
+
SQLMesh’s `plan` command is the primary tool for understanding the effects of changes you make to your project. If your project files have changed or are different from the state of an environment, you execute `sqlmesh plan [environment name]` to synchronize the environment's state with your project files. `sqlmesh plan` will generate a summary of the actions needed to implement the changes, run unit tests for models included in the plan, and prompt you to `apply` the plan and implement the changes.
130
130
131
131
If your project files have not changed, you execute `sqlmesh run` to run your project's models and audits.
132
132
@@ -210,7 +210,7 @@
210
210
- Configure your project and set up a project database (using DuckDB locally or a database connection)
211
211
- Create, configure, and modify models, audits, tests, and other project components
212
212
- Execute `sqlmesh plan [environment name]` to:
213
-
- Generate a summary of the differences between your project files and the environment and whether each change is `breaking`. The `plan` includes a list of the actions needed to implement the changes and automatically runs the project's unit `test`s.
213
+
- Generate a summary of the differences between your project files and the environment and whether each change is `breaking`. The `plan` includes a list of the actions needed to implement the changes and runs unit `test`s for models included in the plan.
214
214
- Optionally apply the plan to implement the actions and run the project's `audit`s.
215
215
- Execute `sqlmesh run` on a schedule to ingest and transform new data
Copy file name to clipboardExpand all lines: docs/guides/models.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,7 +161,11 @@ Reverting to a previous model version is a quick operation since no additional w
161
161
162
162
SQLMesh automatically validates your models in order to ensure the quality and accuracy of your data. This is done via the following:
163
163
164
-
* 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.
164
+
* Running unit tests for models in the plan when you execute the `plan` command (use `--all-tests` for the full suite, or `--skip-tests` to skip). This ensures changes applied to any environment are logically validated. Refer to [testing](../concepts/tests.md) for more information.
165
+
166
+
!!! important
167
+
168
+
`--skip-backfill` / `--dry-run` plans skip unit tests by default. Pass `--all-tests` if you still want tests to run.
165
169
* 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.
166
170
167
171
SQLMesh also provides automatic validation via CI/CD by automatically creating a preview environment.
Copy file name to clipboardExpand all lines: docs/guides/testing.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,12 @@ OK
12
12
```
13
13
As the unit tests run, SQLMesh will identify any that fail.
14
14
15
+
By default, `sqlmesh plan` runs unit tests only for models included in the plan (added, modified, or restated). Plans with no such models skip unit tests. Use `--all-tests` to run the full suite, or `--skip-tests` to run none.
16
+
17
+
!!! important
18
+
19
+
`--skip-backfill` / `--dry-run` plans skip unit tests by default. Pass `--all-tests` if you still want the full suite to run.
20
+
15
21
For more information about tests, refer to [testing](../concepts/tests.md).
0 commit comments