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
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)
231
248
232
249
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()`).
Enter the backfill end date (eg. '1 month ago', '2020-01-01') or blank to backfill up until'2024-09-27 00:00:00':
247
247
```
248
248
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
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
+
249
306
### Data preview for forward-only changes
250
307
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.
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.
Copy file name to clipboardExpand all lines: docs/integrations/github.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -293,12 +293,14 @@ Below is an example of how to define the default config for the bot in either YA
293
293
| `enable_deploy_command` | Indicates if the `/deploy` command should be enabled in order to allowed synchronized deploys to production. Default: `False`| bool | N |
294
294
| `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 |
295
295
| `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 |
297
298
| `skip_pr_backfill` | Indicates if the bot should skip backfilling models in the PR environment. Default: `True`| bool | N |
298
299
| `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 |
299
300
| `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 |
300
301
| `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 |
Copy file name to clipboardExpand all lines: docs/reference/cli.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
@@ -149,7 +149,7 @@ Options:
149
149
```
150
150
Usage: sqlmesh destroy
151
151
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.
Copy file name to clipboardExpand all lines: docs/reference/notebook.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
@@ -250,7 +250,7 @@ options:
250
250
```
251
251
%destroy
252
252
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.
0 commit comments