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/guides/configuration.md
+73-24Lines changed: 73 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,6 +151,55 @@ The examples specify a Snowflake connection whose password is stored in an envir
151
151
)
152
152
```
153
153
154
+
#### Default target environment
155
+
156
+
The SQLMesh `plan` command acts on the `prod` environment by default (i.e., `sqlmesh plan` is equivalent to `sqlmesh plan prod`).
157
+
158
+
In some organizations, users never run plans directly against `prod` - they do all SQLMesh work in a development environment unique to them. In a standard SQLMesh configuration, this means they need to include their development environment name every time they issue the `plan` command (e.g., `sqlmesh plan dev_tony`).
159
+
160
+
If your organization works like this, it may be convenient to change the `plan` command's default environment from `prod` to each user's development environment. That way people can issue `sqlmesh plan` without typing the environment name every time.
161
+
162
+
The SQLMesh configuration `user()` function returns the name of the user currently logged in and running SQLMesh. It retrieves the username from system environment variables like `USER` on MacOS/Linux or `USERNAME` on Windows.
163
+
164
+
Call `user()` inside Jinja curly braces with the syntax `{{ user() }}`, which allows you to combine the user name with a prefix or suffix.
165
+
166
+
The example configuration below constructs the environment name by appending the username to the end of the string `dev_`. If the user running SQLMesh is `tony`, the default target environment when they run SQLMesh will be `dev_tony`. In other words, `sqlmesh plan` will be equivalent to `sqlmesh plan dev_tony`.
167
+
168
+
=== "YAML"
169
+
170
+
Default target environment is `dev_` combined with the username running SQLMesh.
171
+
172
+
```yaml
173
+
default_target_environment: dev_{{ user() }}
174
+
```
175
+
176
+
=== "Python"
177
+
178
+
Default target environment is `dev_` combined with the username running SQLMesh.
179
+
180
+
Retrieve the username with the `getpass.getuser()` function, and combine it with `dev_` in a Python f-string.
Environment variables have the highest precedence among configuration methods, as [noted above](#configuration-files). They will automatically override configuration file specifications if they follow a specific naming structure.
Even though the second change should have been a metadata change (thus not requiring a backfill), it will still be classified as a breaking change because the comparison is against production instead of the previous development state. This is intentional and may cause additional backfills as more changes are accumulated.
588
+
Even though the second change should have been a metadata change (thus not requiring a backfill), it will still be classified as a breaking change because the comparison is against production instead of the previous development state. This is intentional and may cause additional backfills as more changes are accumulated.
Copy file name to clipboardExpand all lines: docs/reference/notebook.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,9 @@ import sqlmesh
29
29
If desired, you can create the [quickstart example project](../quick_start.md) with the Python `init_example_project` function. The function requires a default SQL dialect for the project's models; this example uses `snowflake`:
30
30
31
31
```python
32
-
from sqlmesh.cli.example_projectimport init_example_project
32
+
from sqlmesh.cli.project_initimport init_example_project
0 commit comments