Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jinja filter defined in DataSource not considered in "Explore Chart" #9328

Closed
lilila opened this issue Mar 19, 2020 · 2 comments
Closed

Jinja filter defined in DataSource not considered in "Explore Chart" #9328

lilila opened this issue Mar 19, 2020 · 2 comments

Comments

@lilila
Copy link

lilila commented Mar 19, 2020

A clear and concise description of what the bug is.

Expected results

I have defined filters in the definition of the data source using jinja template

For instance:
{% set title_target = ' "' + filter_values('title_target', 'Joker' )[0] + '" ' %}

title_target is not a field of the data source itself. I use this variable to generate "readable" subqueries.

{% set title_target_id = ' (SELECT id FROM film_id WHERE title = ' + title_target + ' ORDER BY release_date DESC LIMIT 1)' %}

Which allows me to write my datasource as :

SELECT 
	a,b,c
FROM
	`view_films`
WHERE film_id = {{title_target_allocineid}} and title_comp <> {{ title_target }}


Actual results

This logic works very well in the context of dashboard. However if I click on "Explore Chart" for a chart based on this datasource the chart always displays data for 'Joker' which is the default value (as we set title_target = ' "' + filter_values('title_target', 'Joker' )[0] ) even if the filter "title_target" is set up.

How do I get "explore chart" view to load filter_values ?

Screenshots

Screenshot 2020-03-19 at 14 34 29

You can see on this plot the title_target filter set to "Miss" and the result shows "Joker" the default "filter_value"

Environment

(please complete the following information):

  • superset version: superset 0.36.0.rc1
@villebro
Copy link
Member

Thanks for the detailed issue @lilila , I will investigate this.

@lilila
Copy link
Author

lilila commented Mar 25, 2020

Thank you for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants