Documentation version: latest
Colour theme
This section contains 1 rule(s) related to bigquery.
| Code | Name | Aliases | Fix Compatible |
|---|---|---|---|
| BQ01 | bigquery.forbid_with_expressions | - | ❌ |
Forbid BigQuery WITH expressions.
| Property | Value |
|---|---|
| Name | bigquery.forbid_with_expressions |
| Groups | all, bigquery |
| Auto-fixable | No ❌ |
BigQuery's WITH expression assigns variables inside an expression and then evaluates a final expression:
SELECT WITH(a AS 1, b AS a + 1, b * 2) AS total;Some teams prefer to keep statements to CTEs, subqueries or plain expressions, and to avoid this construct entirely. This rule flags every WITH expression in the bigquery dialect.
This rule only applies to the bigquery dialect and is disabled by default. Enable it with the forbid_with_expressions = True flag.
Anti-pattern
Using a WITH expression.
SELECT WITH(a AS 1, a) AS x;Best practice
Rewrite the expression without WITH.
SELECT 1 AS x;Configuration
| Option | Description |
|---|---|
forbid_with_expressions | If True, flag every BigQuery WITH expression. Defaults to False. Must be one of [True, False]. |