Reputation: 1
I can use the following query with JINJA in Superset's SQL Lab:
SELECT {{ current_username() }}
and it returns the user name. But when I use the following query:
SELECT *
FROM tbl
WHERE dttm_col > '{{ from_dttm }}' and dttm_col < '{{ to_dttm }}'
it returns this error:
Failed to execute query '128'. The following parameters in your query are undefined: 'from_dttm", "to_dttm". Please check your templates parameters for syntax errors and make sure they match across your SQL query and et Parameters.
Upvotes: 0
Views: 174
Reputation: 306
To add those parameters you have to:
In my example I have this query
SELECT order_number, order_date, sales
FROM cleaned_sales_data
WHERE TRUE
{% if from_dttm is not none %}
AND order_date > '{{ from_dttm }}'
{% endif %}
{% if to_dttm is not none %}
AND order_date < '{{ to_dttm }}'
{% endif %}
and I added the following parameters:
{
"from_dttm": "2003-05-01",
"to_dttm": "2003-06-01"
}
and then you get the proper results based on the given parameters
Upvotes: 0