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:
Screen Shot 2018-11-23 at 1.05.38 PM.png


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.:
Screen Shot 2018-11-23 at 1.30.44 PM.png


 

This content is subject to limited support.                

Version history
Last update:
‎07-07-2021 12:45 PM
Updated by: