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/concepts/macros/macro_variables.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,4 +140,5 @@ SQLMesh provides additional predefined variables used to modify model behavior b
140
140
The following variables are also available in [`before_all` and `after_all` statements](../../guides/configuration.md#before_all-and-after_all-statements), as well as in macros invoked within them.
141
141
142
142
* @this_env - A string value containing the name of the current [environment](../environments.md).
143
-
*@schemas - A list of the schema names of the [virtual layer](../../concepts/glossary.md#virtual-layer) of the current environment.
143
+
*@schemas - A list of the schema names of the [virtual layer](../../concepts/glossary.md#virtual-layer) of the current environment.
144
+
*@views - A list of the views names of the [virtual layer](../../concepts/glossary.md#virtual-layer) of the current environment.
Copy file name to clipboardExpand all lines: docs/guides/configuration.md
+9-17Lines changed: 9 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -675,7 +675,7 @@ Configuration for a connection used to run unit tests. An in-memory DuckDB datab
675
675
676
676
### Scheduler
677
677
678
-
Identifies which scheduler backend to use. The scheduler backend is used both for storing metadata and for executing [plans](../concepts/plans.md). By default, the scheduler type is set to `builtin`, which uses the existing SQL engine to store metadata.
678
+
Identifies which scheduler backend to use. The scheduler backend is used both for storing metadata and for executing [plans](../concepts/plans.md). By default, the scheduler type is set to `builtin`, which uses the existing SQL engine to store metadata.
679
679
680
680
These options are in the [scheduler](../reference/configuration.md#scheduler) section of the configuration reference page.
681
681
@@ -1023,16 +1023,15 @@ from sqlmesh.core.snapshot.definition import to_view_mapping
f"GRANT SELECT ON VIEW {view_name} TO ROLE admin_role;"
1032
-
for view_name in mapping.values()
1028
+
f"GRANT SELECT ON VIEW {view_name} /* sqlglot.meta replace=false */ TO ROLE admin_role;"
1029
+
for view_name in evaluator.views
1033
1030
]
1034
1031
```
1035
1032
1033
+
By including the comment `/* sqlglot.meta replace=false */`, you further ensure that the evaluator does not replace the view name with the physical table name during rendering.
1034
+
1036
1035
##### Example: Granting Schema Privileges
1037
1036
1038
1037
Similarly, you can define a macro to grant schema usage privileges and, as demonstrated in the configuration above, using `this_env` macro conditionally execute it only in the production environment.
if evaluator.this_env == "prod" and evaluator.schemas:
1053
1045
return [
1054
1046
f"GRANT USAGE ON SCHEMA {schema} TO admin_role;"
1055
-
for schema in schemas
1047
+
for schema in evaluator.schemas
1056
1048
]
1057
1049
```
1058
1050
1059
-
As demonstrated in these examples, the `environment_naming_info` is available within the macro evaluator for macros invoked within the `before_all` and `after_all` statements. Additionally, the macro `this_env` provides access to the current environment name, which can be helpful for more advanced use cases that require fine-grained control over their behaviour.
1051
+
As demonstrated in these examples, the `schemas` and `views` are available within the macro evaluator for macros invoked within the `before_all` and `after_all` statements. Additionally, the macro `this_env` provides access to the current environment name, which can be helpful for more advanced use cases that require fine-grained control over their behaviour.
0 commit comments