Skip to content

Commit d3e839a

Browse files
authored
Merge branch 'main' into feature/DRM/simplify-java-installation-in-devcontainer
2 parents 2d6d1fa + b1e36b9 commit d3e839a

26 files changed

Lines changed: 423 additions & 36 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ jobs:
457457
strategy:
458458
fail-fast: false
459459
matrix:
460-
dbt-version: ['1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10', '1.11']
460+
dbt-version: ['1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10', '1.11', '1.12']
461461
steps:
462462
- uses: actions/checkout@v7
463463
- name: Set up Python

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ install-dev-dbt-%:
3333
echo "Installing dbt version: $$version"; \
3434
cp pyproject.toml pyproject.toml.backup; \
3535
$(SED_INPLACE) 's/"pydantic>=2.0.0"/"pydantic"/g' pyproject.toml; \
36-
if [ "$$version" = "1.10.0" ] || [ "$$version" = "1.11.0" ]; then \
36+
if [ "$$version" = "1.10.0" ] || [ "$$version" = "1.11.0" ] || [ "$$version" = "1.12.0" ]; then \
3737
echo "Applying special handling for dbt $$version"; \
3838
$(SED_INPLACE) -E 's/"(dbt-core)[^"]*"/"\1~='"$$version"'"/g' pyproject.toml; \
3939
$(SED_INPLACE) -E 's/"(dbt-(bigquery|duckdb|snowflake|athena-community|clickhouse|redshift|trino))[^"]*"/"\1"/g' pyproject.toml; \

docs/concepts/overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ Bad data is worse than no data. The best way to keep bad data out of your system
5252
### [Tests](./tests.md)
5353
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.
5454

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 all unit tests when a `plan` is created. Use `--test-changed-only` to run tests only for models included in the plan (added, modified, or restated), `--skip-tests` to skip, run tests for specific models with [`sqlmesh test --select-model`](../reference/cli.md#test), or run the full suite on demand with the [`test` command](../reference/cli.md#test).
56+
57+
Learn more in the [testing guide](../guides/testing.md).
5658

5759
### [Audits](./audits.md)
5860
In contrast to tests, SQLMesh "audits" validate the results of model code applied to your actual data.

docs/concepts/tests.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Testing
22

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 all unit tests. Use `--test-changed-only` to run tests only for models included in the plan (added, modified, or restated), or `--skip-tests` to run none. With both `--select-model` and `--test-changed-only`, tests run only for selected models that changed.
46

57
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.
68

docs/faq/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
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).
103103

104104
??? 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 all unit tests when `sqlmesh plan` is executed (use `--test-changed-only` to run only tests for models in the plan).
106106

107107
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.
108108

docs/guides/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Reverting to a previous model version is a quick operation since no additional w
161161
162162
SQLMesh automatically validates your models in order to ensure the quality and accuracy of your data. This is done via the following:
163163
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 all unit tests when you execute the `plan` command (use `--test-changed-only` to run only tests for models in the plan). This ensures changes applied to any environment are logically validated. Refer to [testing](../concepts/tests.md) for more information.
165165
* 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.
166166
167167
SQLMesh also provides automatic validation via CI/CD by automatically creating a preview environment.

docs/guides/testing.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@ OK
1212
```
1313
As the unit tests run, SQLMesh will identify any that fail.
1414

15+
By default, `sqlmesh plan` runs all unit tests. Use `--test-changed-only` to run tests only for models included in the plan (added, modified, or restated), or `--skip-tests` to run none. With both `--select-model` and `--test-changed-only`, tests run only for selected models that changed.
16+
1517
For more information about tests, refer to [testing](../concepts/tests.md).
1618

1719
### Test changes to a specific model
1820

19-
To run a specific model test, pass in the suite file name followed by `::` and the name of the test; for example: `sqlmesh test tests/test_suite.yaml::test_example_full_model`.
21+
To run unit tests for a specific model, use `--select-model`:
22+
23+
```bash
24+
$ sqlmesh test --select-model sqlmesh_example.full_model
25+
```
26+
27+
Alternatively, pass in the suite file name followed by `::` and the name of the test; for example: `sqlmesh test tests/test_suite.yaml::test_example_full_model`.
2028

2129
### Run a subset of tests
2230

docs/integrations/dbt.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,12 @@ If set to `False`, then the snapshot will be skipped and a warning will be logge
287287
Support for this will be added soon.
288288

289289
## Tests
290-
SQLMesh uses dbt tests to perform SQLMesh [audits](../concepts/audits.md) (coming soon).
291290

292-
Add SQLMesh [unit tests](../concepts/tests.md) to a dbt project by placing them in the "tests" directory.
291+
dbt and SQLMesh use the word "test" differently. See [Workflow differences](#workflow-differences-between-sqlmesh-and-dbt) above for an overview.
292+
293+
SQLMesh converts dbt tests (singular and generic `.sql` files in the `tests/` directory) into SQLMesh [audits](../concepts/audits.md). These run against data that already exists in your tables, just like dbt tests.
294+
295+
Add SQLMesh [unit tests](../concepts/tests.md) to a dbt project by placing YAML files named `test*.yaml` or `test*.yml` in the `tests/` directory. Unit tests validate model query logic with predefined inputs and expected outputs; they are separate from dbt's SQL test files.
293296

294297
## Seed column types
295298

docs/reference/cli.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ Options:
357357
Default: prod.
358358
--skip-tests Skip tests prior to generating the plan if
359359
they are defined.
360+
--test-changed-only Run unit tests only for models included in
361+
the plan instead of all tests.
360362
--skip-linter Skip linting prior to generating the plan if
361363
the linter is enabled.
362364
-r, --restate-model TEXT Restate data for specified models and models
@@ -626,6 +628,8 @@ Options:
626628
-v, --verbose Verbose output.
627629
--preserve-fixtures Preserve the fixture tables in the testing database,
628630
useful for debugging.
631+
--select-model TEXT Select specific models to run unit tests for. Can be
632+
specified multiple times.
629633
--help Show this message and exit.
630634
```
631635

docs/reference/notebook.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ options:
9696
#### plan
9797
```
9898
%plan [--start START] [--end END] [--execution-time EXECUTION_TIME]
99-
[--create-from CREATE_FROM] [--skip-tests]
99+
[--create-from CREATE_FROM] [--skip-tests] [--test-changed-only]
100100
[--restate-model [RESTATE_MODEL ...]] [--no-gaps]
101101
[--skip-backfill, --dry-run] [--forward-only]
102102
[--effective-from EFFECTIVE_FROM] [--no-prompts] [--auto-apply]
@@ -120,6 +120,8 @@ options:
120120
The environment to create the target environment from
121121
if it doesn't exist. Default: prod.
122122
--skip-tests, -t Skip the unit tests defined for the model.
123+
--test-changed-only Run unit tests only for models included in the plan
124+
instead of all tests.
123125
--restate-model <[RESTATE_MODEL ...]>, -r <[RESTATE_MODEL ...]>
124126
Restate data for specified models (and models
125127
downstream from the one specified). For production
@@ -131,7 +133,8 @@ options:
131133
comparing to existing snapshots for matching models in
132134
the target environment.
133135
--skip-backfill, --dry-run
134-
Skip the backfill step and only create a virtual update for the plan.
136+
Skip the backfill step and only create a virtual
137+
update for the plan.
135138
--forward-only Create a plan for forward-only changes.
136139
--effective-from EFFECTIVE_FROM
137140
The effective date from which to apply forward-only
@@ -430,7 +433,8 @@ options:
430433

431434
#### run_test
432435
```
433-
%run_test [--pattern [PATTERN ...]] [--verbose] [--preserve-fixtures] [tests ...]
436+
%run_test [--pattern [PATTERN ...]] [--verbose] [--preserve-fixtures]
437+
[--select-model [SELECT_MODEL ...]] [tests ...]
434438
435439
Run unit test(s).
436440
@@ -443,6 +447,8 @@ options:
443447
--verbose, -v Verbose output.
444448
--preserve-fixtures Preserve the fixture tables in the testing database,
445449
useful for debugging.
450+
--select-model <[SELECT_MODEL ...]>
451+
Select specific models to run unit tests for.
446452
```
447453

448454
#### audit

0 commit comments

Comments
 (0)