Search code examples
sqlalchemyjinja2apache-superset

What is the proper syntax for usage jinja templates for columns in superset?


Here https://superset.apache.org/docs/installation/sql-templating/ described several parameters for handling columns:

  • columns: columns which to group by in the query
  • groupby: columns which to group by in the query (deprecated)
  • table_columns: columns available in the dataset
  • time_column: temporal column of the query (None if undefined)

How should I use these parameters?

I've tried this manual https://www.preset.io/blog/intro-jinja-templating-apache-superset/ but this is for values not for columns


Solution

  • Here is a syntax for table_columns and time_column:

    SELECT 
        {{ ', '.join(table_columns) }}
    from my_table where {{ time_column }} < '{{ from_dttm }}'
    limit 100