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/examples/sqlmesh_cli_crash_course.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -738,6 +738,11 @@ You'll use these commands as needed to validate that your changes are behaving a
738
738
739
739
This is a great way to verify that your model's SQL is looking as expected before applying the changes. It is especially important if you're migrating from one query engine to another (ex: postgres to databricks).
740
740
741
+
In large projects, add `--use-project-index` to load only the model being rendered and its upstream
742
+
dependencies. To enable this behavior by default, set
743
+
[`render.use_project_index`](../reference/configuration.md#render) to `true` in the project
744
+
configuration.
745
+
741
746
=== "SQLMesh"
742
747
743
748
```bash
@@ -1254,4 +1259,4 @@ If you notice you have a lot of old development schemas/data, you can clean them
Copy file name to clipboardExpand all lines: docs/guides/configuration.md
+31-1Lines changed: 31 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,7 @@ The `config` sub-module API documentation describes the individual classes used
90
90
- [Connection configuration](https://sqlmesh.readthedocs.io/en/latest/_readthedocs/html/sqlmesh/core/config/connection.html) (separate classes for each supported database/engine)
91
91
- [Scheduler configuration](https://sqlmesh.readthedocs.io/en/latest/_readthedocs/html/sqlmesh/core/config/scheduler.html) (separate classes for each supported scheduler)
- [Notification configuration](https://sqlmesh.readthedocs.io/en/latest/_readthedocs/html/sqlmesh/core/notification_target.html) (separate classes for each notification target)
95
96
@@ -331,7 +332,7 @@ The cache directory is automatically created if it doesn't exist. You can clear
331
332
332
333
#### Project index
333
334
334
-
The `--use-project-index` option on supported commands maintains a persistent model dependency index in the cache directory. Each project writes a file named `<project>_<hash>_model_index.json`.
335
+
The `--use-project-index` option on the `lint` and `render` commands maintains a persistent model dependency index in the cache directory. Each project writes a file named `<project>_<hash>_model_index.json`. The option can be enabled by default for each command with `linter.use_project_index` or `render.use_project_index`, respectively.
335
336
336
337
A full project load with the option enabled creates or refreshes the index. SQLMesh invalidates it when relevant configuration, gateway, macro, audit, or signal metadata changes, or when the set of model files changes. If the index is missing, invalid, or stale, SQLMesh safely falls back to a full project load and rebuilds it.
337
338
@@ -1503,6 +1504,35 @@ SQLMesh provides a linter that checks for potential issues in your models' code.
1503
1504
1504
1505
Learn more about linting configuration in the [linting guide](./linter.md).
1505
1506
1507
+
### Rendering
1508
+
1509
+
By default, `sqlmesh render` loads every model in the project. In large projects, you can use the
1510
+
persistent project index to load only the model being rendered and its transitive upstream
1511
+
dependencies. Enable indexed rendering for an individual command with `--use-project-index`, or
1512
+
make it the project default with the `render.use_project_index` configuration option.
1513
+
1514
+
=== "YAML"
1515
+
1516
+
```yaml linenums="1"
1517
+
render:
1518
+
use_project_index: true
1519
+
```
1520
+
1521
+
=== "Python"
1522
+
1523
+
```python linenums="1"
1524
+
from sqlmesh.core.config import Config, ModelDefaultsConfig, RenderConfig
Copy file name to clipboardExpand all lines: docs/reference/configuration.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
@@ -67,6 +67,12 @@ See all the keys allowed in `model_defaults` at the [model configuration referen
67
67
|`linter.enabled`| Whether linting is enabled (Default: `False`) | boolean | N |
68
68
|`linter.use_project_index`| Whether to use the persistent project index for linting. Targeted linting loads selected models and their upstream dependencies. (Default: `False`) | boolean | N |
|`render.use_project_index`| Whether to use the persistent project index when rendering. Only the target model and its upstream dependencies are loaded. (Default: `False`) | boolean | N |
75
+
70
76
### Variables
71
77
72
78
The `variables` key can be used to provide values for user-defined variables, accessed using the [`@VAR` macro function](../concepts/macros/sqlmesh_macros.md#global-variables) in SQL model definitions, [`context.var` method](../concepts/models/python_models.md#global-variables) in Python model definitions, and [`evaluator.var` method](../concepts/macros/sqlmesh_macros.md#accessing-global-variable-values) in Python macro functions.
Copy file name to clipboardExpand all lines: sqlmesh/cli/main.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -287,7 +287,8 @@ def init(
287
287
@click.option(
288
288
"--use-project-index",
289
289
is_flag=True,
290
-
help="Use the persistent project index to load and render only the target model and its upstream dependencies.",
290
+
default=None,
291
+
help="Use the persistent project index to load and render only the target model and its upstream dependencies. Can also be enabled with render.use_project_index.",
0 commit comments