Skip to content

Commit 584f314

Browse files
committed
Chore: update docs on @this_model
1 parent 9326a3c commit 584f314

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

docs/concepts/macros/macro_variables.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,19 @@ SQLMesh provides additional predefined variables used to modify model behavior b
130130
* 'auditing' - The audit is being run.
131131
* 'testing' - The model query logic is being evaluated in the context of a unit test.
132132
* @gateway - A string value containing the name of the current [gateway](../../guides/connections.md).
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-
* 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-
* Can be passed as an argument to macros that access or interact with the underlying physical table.
133+
* @this_model - The physical table name that the model's 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.
136134
* @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).
137135

136+
!!! note
137+
138+
The `@{variable}` syntax serves a different purpose from the `@variable` syntax.
139+
140+
In the former, `@{variable}` is replaced by the variable's value and the resulting expression is treated as an identifier, whereas the latter is simply replaced by the expression stored in the variable.
141+
142+
For example, if `variable` is defined as `@DEF(`variable`, foo.bar)`, then `@variable` produces `foo.bar`, while `@{variable}` produces `"foo.bar"`, because `foo.bar` is treated converted into an identifier, making it necessary to add quotes due to the `.` character.
143+
144+
In practice, `@{variable}` is most commonly used to interpolate a value within an identifier, e.g., `@{variable}_suffix`, whereas `@variable` is used to do plain substitutions.
145+
138146
#### Before all and after all variables
139147

140148
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.

0 commit comments

Comments
 (0)