Skip to content

Commit dce1f36

Browse files
Chore: Update and clarify blueprints doc example macro syntax
1 parent 7441d63 commit dce1f36

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

docs/concepts/macros/sqlmesh_macros.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,35 @@ MODEL (
216216
name @customer.some_table,
217217
kind FULL,
218218
blueprints (
219-
(customer := customer1, field_a := x, field_b := y),
220-
(customer := customer2, field_a := z, field_b := w)
219+
(customer := customer1, field_a := x, field_b := y, field_c := 'foo'),
220+
(customer := customer2, field_a := z, field_b := w, field_c := 'bar')
221221
)
222222
);
223223

224224
SELECT
225225
@field_a,
226-
@{field_b} AS field_b
226+
@{field_b} AS field_b,
227+
@field_c AS @{field_c}
227228
FROM @customer.some_source
229+
230+
/*
231+
When rendered for customer1.some_table:
232+
SELECT
233+
x,
234+
y AS field_b,
235+
'foo' AS foo
236+
FROM customer1.some_source
237+
238+
When rendered for customer2.some_table:
239+
SELECT
240+
z,
241+
w AS field_b,
242+
'bar' AS bar
243+
FROM customer2.some_source
244+
*/
228245
```
229246

230-
Note the use of both regular `@field_a` and curly brace syntax `@{field_b}` macro variable references in the model query. Learn more [above](#embedding-variables-in-strings)
247+
Note the use of both regular `@field_a` and curly brace syntax `@{field_b}` macro variable references in the model query. Both of these will be rendered as identifiers. In the case of `field_c`, which in the blueprints is a string, it would be rendered as a string literal when used with the regular macro syntax `@field_c` and if we want to use the string as an identifier then we use the curly braces `@{field_c}`. Learn more [above](#embedding-variables-in-strings)
231248

232249
Blueprint variables can be accessed using the syntax shown above, or through the `@BLUEPRINT_VAR()` macro function, which also supports specifying default values in case the variable is undefined (similar to `@VAR()`).
233250

0 commit comments

Comments
 (0)