Skip to content

Commit f6aee9e

Browse files
committed
2 parents c2c1862 + 87f5335 commit f6aee9e

File tree

110 files changed

+3790
-1008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+3790
-1008
lines changed

.circleci/continue_config.yml

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -201,39 +201,6 @@ jobs:
201201
name: Run tests
202202
command: npm --prefix web/client run test
203203

204-
trigger_private_tests:
205-
docker:
206-
- image: cimg/python:3.12.0
207-
resource_class: small
208-
steps:
209-
- checkout
210-
- run:
211-
name: Install setuptools scm
212-
command: pip install setuptools_scm
213-
- run:
214-
name: Trigger private tests
215-
command: |
216-
export COMMIT_MESSAGE="$(git log --format=%s -n 1 $CIRCLE_SHA1)"
217-
export FORMATTED_COMMIT_MESSAGE="${COMMIT_MESSAGE//\"/\\\"}"
218-
# returns a version string like 0.1.0.dev11
219-
export PACKAGE_VERSION="$(python ./.circleci/get_scm_version.py)"
220-
curl --request POST \
221-
--url $TOBIKO_PRIVATE_CIRCLECI_URL \
222-
--header "Circle-Token: $TOBIKO_PRIVATE_CIRCLECI_KEY" \
223-
--header "content-type: application/json" \
224-
--data '{
225-
"branch":"main",
226-
"parameters":{
227-
"run_main_pr":false,
228-
"run_sqlmesh_commit":true,
229-
"sqlmesh_branch":"'$CIRCLE_BRANCH'",
230-
"sqlmesh_commit_author":"'$CIRCLE_USERNAME'",
231-
"sqlmesh_commit_hash":"'$CIRCLE_SHA1'",
232-
"sqlmesh_commit_message":"'"$FORMATTED_COMMIT_MESSAGE"'",
233-
"sqlmesh_package_version":"'$PACKAGE_VERSION'"
234-
}
235-
}'
236-
237204
engine_tests_docker:
238205
parameters:
239206
engine:
@@ -340,13 +307,6 @@ workflows:
340307
branches:
341308
only:
342309
- main
343-
- trigger_private_tests:
344-
requires:
345-
- style_and_cicd_tests
346-
filters:
347-
branches:
348-
only:
349-
- main
350310
- ui_style
351311
- ui_test
352312
- vscode_test

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
with:
4444
python-version: '3.12'
4545
- name: Install uv
46-
uses: astral-sh/setup-uv@v4
46+
uses: astral-sh/setup-uv@v6
4747
- name: Install python dependencies
4848
run: |
4949
python -m venv .venv

docs/concepts/macros/macro_variables.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ SQLMesh provides additional predefined variables used to modify model behavior b
132132
* 'loading' - The project is being loaded into SQLMesh's runtime context.
133133
* 'creating' - The model tables are being created.
134134
* 'evaluating' - The model query logic is being evaluated.
135-
* 'promoting' - The model is being promoted in the target environment (virtual layer update).
135+
* 'promoting' - The model is being promoted in the target environment (view created during virtual layer update).
136+
* 'demoting' - The model is being demoted in the target environment (view dropped during virtual layer update).
136137
* 'auditing' - The audit is being run.
137138
* 'testing' - The model query logic is being evaluated in the context of a unit test.
138139
* @gateway - A string value containing the name of the current [gateway](../../guides/connections.md).

docs/concepts/macros/sqlmesh_macros.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,35 @@ MODEL (
216216
name @customer.some_table,
217217
kind FULL,
218218
blueprints (
219-
(customer := customer1, field_a := x, field_b := y),
220-
(customer := customer2, field_a := z, field_b := w)
219+
(customer := customer1, field_a := x, field_b := y, field_c := 'foo'),
220+
(customer := customer2, field_a := z, field_b := w, field_c := 'bar')
221221
)
222222
);
223223

224224
SELECT
225225
@field_a,
226-
@{field_b} AS field_b
226+
@{field_b} AS field_b,
227+
@field_c AS @{field_c}
227228
FROM @customer.some_source
229+
230+
/*
231+
When rendered for customer1.some_table:
232+
SELECT
233+
x,
234+
y AS field_b,
235+
'foo' AS foo
236+
FROM customer1.some_source
237+
238+
When rendered for customer2.some_table:
239+
SELECT
240+
z,
241+
w AS field_b,
242+
'bar' AS bar
243+
FROM customer2.some_source
244+
*/
228245
```
229246

230-
Note the use of both regular `@field_a` and curly brace syntax `@{field_b}` macro variable references in the model query. Learn more [above](#embedding-variables-in-strings)
247+
Note the use of both regular `@field_a` and curly brace syntax `@{field_b}` macro variable references in the model query. Both of these will be rendered as identifiers. In the case of `field_c`, which in the blueprints is a string, it would be rendered as a string literal when used with the regular macro syntax `@field_c` and if we want to use the string as an identifier then we use the curly braces `@{field_c}`. Learn more [above](#embedding-variables-in-strings)
231248

232249
Blueprint variables can be accessed using the syntax shown above, or through the `@BLUEPRINT_VAR()` macro function, which also supports specifying default values in case the variable is undefined (similar to `@VAR()`).
233250

docs/concepts/plans.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,63 @@ Models needing backfill (missing dates):
246246
Enter the backfill end date (eg. '1 month ago', '2020-01-01') or blank to backfill up until '2024-09-27 00:00:00':
247247
```
248248
249+
#### Minimum intervals
250+
251+
When you run a plan with a fixed `--start` or `--end` date, you create a virtual data environment with a limited subset of data. However, if the time range specified is less than the size of an interval on one of your models, that model will be skipped by default.
252+
253+
For example, if you have a model like so:
254+
255+
```sql
256+
MODEL(
257+
name sqlmesh_example.monthly_model,
258+
kind INCREMENTAL_BY_TIME_RANGE (
259+
time_column month
260+
),
261+
cron '@monthly'
262+
);
263+
264+
SELECT SUM(a) AS sum_a, MONTH(day) AS month
265+
FROM sqlmesh_example.upstream_model
266+
WHERE day BETWEEN @start_ds AND @end_ds
267+
```
268+
269+
make a change to it and run the following:
270+
271+
```bash linenums="1" hl_lines="8"
272+
$ sqlmesh plan dev --start '1 day ago'
273+
274+
Models:
275+
└── Added:
276+
└── sqlmesh_example__dev.monthly_model
277+
Apply - Virtual Update [y/n]: y
278+
279+
SKIP: No model batches to execute
280+
```
281+
282+
No data will be backfilled because `1 day ago` does not contain a complete month. However, you can use the `--min-intervals` option to override this behaviour like so:
283+
284+
```bash linenums="1" hl_lines="11"
285+
$ sqlmesh plan dev --start '1 day ago' --min-intervals 1
286+
287+
Models:
288+
└── Added:
289+
└── sqlmesh_example__dev.monthly_model
290+
Apply - Virtual Update [y/n]: y
291+
292+
[1/1] sqlmesh_example__dev.monthly_model [insert 2025-06-01 - 2025-06-30] 0.08s
293+
Executing model batches ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 1/1 • 0:00:00
294+
295+
✔ Model batches executed
296+
```
297+
298+
This will ensure that regardless of the plan `--start` date, all added or modified models will have at least `--min-intervals` intervals considered for backfill.
299+
300+
!!! info
301+
302+
If you are running plans manually you can just adjust the `--start` date to be wide enough to cover the models in question.
303+
304+
The `--min-intervals` option is primarily intended for [automation scenarios](../integrations/github.md) where the plan is always run with a default relative start date and you always want (for example) "2 weeks worth of data" in the target environment.
305+
249306
### Data preview for forward-only changes
250307
As mentioned earlier, the data output produced by [forward-only changes](#forward-only-change) in a development environment can only be used for preview and will not be reused in production.
251308

docs/guides/signals.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ This example specifies that the `random_signal()` should evaluate once with a th
6363
MODEL (
6464
name example.signal_model,
6565
kind FULL,
66-
signals [
66+
signals (
6767
random_signal(threshold := 0.5), # specify threshold value
68-
]
68+
)
6969
);
7070

7171
SELECT 1
@@ -108,9 +108,9 @@ MODEL (
108108
time_column ds,
109109
),
110110
start '2 week ago',
111-
signals [
111+
signals (
112112
one_week_ago(),
113-
]
113+
)
114114
);
115115

116116

docs/guides/vscode.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Visual Studio Code Extension
22

3+
<div style="position: relative; padding-bottom: 56.25%; height: 0;"><iframe src="https://www.loom.com/embed/4a2e974ec8294716a4b1dbb0146add82?sid=b6c8def6-b7e0-4bfc-af6c-e37d5d83b0b1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div>
4+
35
!!! danger "Preview"
46

57
The SQLMesh Visual Studio Code extension is in preview and undergoing active development. You may encounter bugs or API incompatibilities with the SQLMesh version you are running.

docs/integrations/github.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,14 @@ Below is an example of how to define the default config for the bot in either YA
293293
| `enable_deploy_command` | Indicates if the `/deploy` command should be enabled in order to allowed synchronized deploys to production. Default: `False` | bool | N |
294294
| `command_namespace` | The namespace to use for SQLMesh commands. For example if you provide `#SQLMesh` as a value then commands will be expected in the format of `#SQLMesh/<command>`. Default: `None` meaning no namespace is used. | string | N |
295295
| `auto_categorize_changes` | Auto categorization behavior to use for the bot. If not provided then the project-wide categorization behavior is used. See [Auto-categorize model changes](https://sqlmesh.readthedocs.io/en/stable/guides/configuration/#auto-categorize-model-changes) for details. | dict | N |
296-
| `default_pr_start` | Default start when creating PR environment plans. If running in a mode where the bot automatically backfills models (based on `auto_categorize_changes` behavior) then this can be used to limit the amount of data backfilled. Defaults to `None` meaning the start date is set to the earliest model's start or to 1 day ago if [data previews](../concepts/plans.md#data-preview) need to be computed. | str | N |
296+
| `default_pr_start` | Default start when creating PR environment plans. If running in a mode where the bot automatically backfills models (based on `auto_categorize_changes` behavior) then this can be used to limit the amount of data backfilled. Defaults to `None` meaning the start date is set to the earliest model's start or to 1 day ago if [data previews](../concepts/plans.md#data-preview) need to be computed.| str | N |
297+
| `pr_min_intervals` | Intended for use when `default_pr_start` is set to a relative time, eg `1 week ago`. This ensures that at least this many intervals across every model are included for backfill in the PR environment. Without this, models with an interval unit wider than `default_pr_start` (such as `@monthly` models if `default_pr_start` was set to `1 week ago`) will be excluded from backfill entirely. | int | N |
297298
| `skip_pr_backfill` | Indicates if the bot should skip backfilling models in the PR environment. Default: `True` | bool | N |
298299
| `pr_include_unmodified` | Indicates whether to include unmodified models in the PR environment. Default to the project's config value (which defaults to `False`) | bool | N |
299300
| `run_on_deploy_to_prod` | Indicates whether to run latest intervals when deploying to prod. If set to false, the deployment will backfill only the changed models up to the existing latest interval in production, ignoring any missing intervals beyond this point. Default: `False` | bool | N |
300301
| `pr_environment_name` | The name of the PR environment to create for which a PR number will be appended to. Defaults to the repo name if not provided. Note: The name will be normalized to alphanumeric + underscore and lowercase. | str | N |
301-
| `prod_branch_name` | The name of the git branch associated with production. Ex: `prod`. Default: `main` or `master` is considered prod | str | N |
302+
| `prod_branch_name` | The name of the git branch associated with production. Ex: `prod`. Default: `main` or `master` is considered prod | str | N |
303+
| `forward_only_branch_suffix` | If the git branch has this suffix, trigger a [forward-only](../concepts/plans.md#forward-only-plans) plan instead of a normal plan. Default: `-forward-only` | str | N |
302304

303305
Example with all properties defined:
304306

docs/reference/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Options:
149149
```
150150
Usage: sqlmesh destroy
151151
152-
Removes all project resources, including warehouse objects, state tables, the SQLMesh cache and any build artifacts.
152+
Removes all state tables, the SQLMesh cache and all project resources, including warehouse objects. This includes all tables, views and schemas managed by SQLMesh, as well as any external resources that may have been created by other tools within those schemas.
153153
154154
Options:
155155
--help Show this message and exit.

docs/reference/notebook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ options:
250250
```
251251
%destroy
252252
253-
Removes all project resources, including warehouse objects, state tables, the SQLMesh cache and any build artifacts.
253+
Removes all state tables, the SQLMesh cache, and other project resources, including warehouse objects. This includes all tables, views, and schemas managed by SQLMesh, as well as any external resources that may have been created by other tools within those schemas.
254254
```
255255

256256
#### dlt_refresh

0 commit comments

Comments
 (0)