Skip to content

Commit cfadb20

Browse files
committed
docs: document automatic parenthesization of compound member references (follow-up to #10724)
1 parent ddf77f2 commit cfadb20

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • docs-mintlify/docs/data-modeling/concepts

docs-mintlify/docs/data-modeling/concepts/syntax.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,19 @@ cube(`users`, {
278278

279279
</CodeGroup>
280280

281+
<Note>
282+
283+
You can safely reference a member whose `sql` is a compound expression, such as
284+
arithmetic (`{price} + {tax}`) or boolean logic (`{is_paid} OR {is_pending}`). When you
285+
reference such a member inside an arithmetic or logical expression, Cube wraps it in
286+
parentheses automatically, so operator precedence is preserved. For example, if
287+
`price_with_tax` is defined as `{price} + {tax}`, then referencing it as
288+
`{price_with_tax} * {quantity}` generates `(price + tax) * quantity`. Cube only adds these
289+
parentheses where they are needed — a reference that already sits in a safe position, such as
290+
a function argument (`ABS({price_with_tax})`) or a `CAST(...)`, is left unwrapped.
291+
292+
</Note>
293+
281294
This syntax works great for simple use cases. However, there are cases
282295
(like [subquery][ref-subquery]) when you'd like to reference members of
283296
other cubes. See below how to do that.

0 commit comments

Comments
 (0)