Skip to content

Commit ab92e3f

Browse files
authored
Chore: update blueprint docs (#5714)
1 parent d8d653f commit ab92e3f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

docs/concepts/models/sql_models.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ MODEL (
149149

150150
SELECT
151151
@field_a,
152-
@{field_b} AS field_b
152+
@{field_b} AS field_b,
153+
@'prefix_@{field_a}_suffix' AS literal_example
153154
FROM @customer.some_source
154155
```
155156

@@ -163,8 +164,9 @@ MODEL (
163164
);
164165

165166
SELECT
166-
'x',
167-
y AS field_b
167+
x,
168+
y AS field_b,
169+
'prefix_x_suffix' AS literal_example
168170
FROM customer1.some_source
169171

170172
-- This uses the second variable mapping
@@ -174,14 +176,13 @@ MODEL (
174176
);
175177

176178
SELECT
177-
'z',
178-
w AS field_b
179+
z,
180+
w AS field_b,
181+
'prefix_z_suffix' AS literal_example
179182
FROM customer2.some_source
180183
```
181184

182-
Note the use of curly brace syntax `@{field_b} AS field_b` in the model query above. It is used to tell SQLMesh that the rendered variable value should be treated as a SQL identifier instead of a string literal.
183-
184-
You can see the different behavior in the first rendered model. `@field_a` is resolved to the string literal `'x'` (with single quotes) and `@{field_b}` is resolved to the identifier `y` (without quotes). Learn more about the curly brace syntax [here](../../concepts/macros/sqlmesh_macros.md#embedding-variables-in-strings).
185+
Both `@field_a` and `@{field_b}` resolve blueprint variable values as SQL identifiers. The curly brace syntax is useful when embedding a variable within a larger string where the variable boundary would otherwise be ambiguous (e.g. `@{customer}_suffix`). To produce a string literal with interpolated variables, use the `@'...@{var}...'` syntax as shown with `literal_example` above. Learn more about the curly brace syntax [here](../../concepts/macros/sqlmesh_macros.md#embedding-variables-in-strings).
185186

186187
Blueprint variable mappings can also be constructed dynamically, e.g., by using a macro: `blueprints @gen_blueprints()`. This is useful in cases where the `blueprints` list needs to be sourced from external sources, such as CSV files.
187188

0 commit comments

Comments
 (0)