Jinja runs before the warehouse executes SQL.
Expressions inside double braces produce text, while statement blocks control how that text is assembled. A set block stores a value, a for block repeats a section, and an if block chooses a section. Compile the model to see the final SQL the warehouse receives.
Treat Jinja as a code generator. A list of columns needs commas between generated expressions, but not a trailing comma after the last one. Whitespace control removes surrounding spaces or newlines; careless trimming can glue SQL tokens together.
Filters such as upper, lower, join, and default transform Jinja values before rendering. They don't clean values inside a warehouse column. Use SQL functions for row values, and use Jinja to organize the query itself.