What purpose does the `sql:` clause in a Templated Filter serve?

Knowledge Drop

Last tested: Nov 23, 2018

The sql: clause in a Templated Filter gets injected directly into the WHERE clause of your query.

For example we can add this to the sql: of a filter :

filter: place_where_the_user_can_input_something {    type: string    sql: {% condition %} ${client} {% endcondition %} ;;  }

Which, when utilized in the UI, generates a filter only field that generates the following SQL in the WHERE:

Note: that within the definition of the filter we can refer to the filter itself (without naming/scoping it) by using {% condition %} instead of the more familiar {% condition filter_name %} or {% condition view_name.filter_name %} syntax.

Note 2: The same behavior displayed above would be achieved by including the templated filter reference (but this time fully scoped) in the sql_always_where: at the explore level. i.e.: