From b9ac800bfb087ee5c08bbfa41e9362d0cadf3f87 Mon Sep 17 00:00:00 2001 From: Sam Firke Date: Tue, 29 Oct 2024 13:00:46 -0400 Subject: [PATCH] docs(templating): Replace "true" with "1 = 1" and explain its purpose (#30743) --- docs/docs/configuration/sql-templating.mdx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/docs/configuration/sql-templating.mdx b/docs/docs/configuration/sql-templating.mdx index 64caea215..39bea00d8 100644 --- a/docs/docs/configuration/sql-templating.mdx +++ b/docs/docs/configuration/sql-templating.mdx @@ -48,12 +48,15 @@ WHERE ( {% if to_dttm is not none %} dttm_col < '{{ to_dttm }}' AND {% endif %} - true + 1 = 1 ) ``` -Note how the Jinja parameters are called within double brackets in the query, and without in the -logic blocks. +The `1 = 1` at the end ensures a value is present for the `WHERE` clause even when +the time filter is not set. For many database engines, this could be replaced with `true`. + +Note that the Jinja parameters are called within _double_ brackets in the query and with +_single_ brackets in the logic blocks. To add custom functionality to the Jinja context, you need to overload the default Jinja context in your environment by defining the `JINJA_CONTEXT_ADDONS` in your superset configuration