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
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ This example used one of SQLMesh's predefined variables, but you can also define
44
44
45
45
We describe SQLMesh's predefined variables below; user-defined macro variables are discussed in the [SQLMesh macros](./sqlmesh_macros.md#user-defined-variables) and [Jinja macros](./jinja_macros.md#user-defined-variables) pages.
46
46
47
-
## Predefined Variables
47
+
## Predefined variables
48
48
SQLMesh comes with predefined variables that can be used in your queries. They are automatically set by the SQLMesh runtime.
49
49
50
50
Most predefined variables are related to time and use a combination of prefixes (start, end, etc.) and postfixes (date, ds, ts, etc.). They are described in the next section; [other predefined variables](#runtime-variables) are discussed in the following section.
@@ -120,7 +120,7 @@ All predefined temporal macro variables:
120
120
121
121
### Runtime variables
122
122
123
-
SQLMesh provides two other predefined variables used to modify model behavior based on information available at runtime.
123
+
SQLMesh provides additional predefined variables used to modify model behavior based on information available at runtime.
124
124
125
125
* @runtime_stage - A string value denoting the current stage of the SQLMesh runtime. Typically used in models to conditionally execute pre/post-statements (learn more [here](../models/sql_models.md#optional-prepost-statements)). It returns one of these values:
126
126
* 'loading' - The project is being loaded into SQLMesh's runtime context.
@@ -133,5 +133,11 @@ SQLMesh provides two other predefined variables used to modify model behavior ba
133
133
* @this_model - A string value containing the name of the physical table the model view selects from. Typically used to create [generic audits](../audits.md#generic-audits). In the case of [on_virtual_update statements](../models/sql_models.md#optional-on-virtual-update-statements) it contains the qualified view name instead.
134
134
* Can be used in model definitions when SQLGlot cannot fully parse a statement and you need to reference the model's underlying physical table directly.
135
135
* Can be passed as an argument to macros that access or interact with the underlying physical table.
136
-
* @this_env - A string value containing the name of the current [environment](../environments.md). Only 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.
137
-
* @model_kind_name - A string value containing the name of the current model kind. Intended to be used in scenarios where you need to control the [physical properties in model defaults](../../reference/model_configuration.md#model-defaults).
136
+
* @model_kind_name - A string value containing the name of the current model kind. Intended to be used in scenarios where you need to control the [physical properties in model defaults](../../reference/model_configuration.md#model-defaults).
137
+
138
+
#### Before all and after all variables
139
+
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
+
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.
0 commit comments