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 Template not working in case of view query #8892

Closed
3 tasks
saurabh1-singh opened this issue Dec 24, 2019 · 7 comments
Closed
3 tasks

Jinja Template not working in case of view query #8892

saurabh1-singh opened this issue Dec 24, 2019 · 7 comments
Labels
!deprecated-label:bug Deprecated label - Use #bug instead inactive Inactive for >= 30 days

Comments

@saurabh1-singh
Copy link

saurabh1-singh commented Dec 24, 2019

When I put the jinja template inside a filter after selecting a table data source directly and then use a filter box to fill those values at runtime it works fine. But when I create a advanced query i.e. view, then the same thing does not work.
Screenshot from 2019-12-24 13-51-04

In the above screenshot you can see the chart test_char is loaded fine but not the test_c_1

Screenshot from 2019-12-24 13-54-04

The above one is test_c_1 with a advanced query/view

Screenshot from 2019-12-24 13-55-08

Expected results

I expected both to work similarly

Actual results

Did not happen in case of view it also creates an extra filter with the name of the filter in filter box and try it apply it too

Screenshots

If applicable, add screenshots to help explain your problem.

How to reproduce the bug

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Environment

(please complete the following information):

  • superset version: superset version
  • python version: python --version
  • node.js version: node -v
  • npm version: npm -v

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

Add any other context about the problem here.

@issue-label-bot issue-label-bot bot added the !deprecated-label:bug Deprecated label - Use #bug instead label Dec 24, 2019
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.93. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@villebro
Copy link
Member

You can look at the generated query to debug similar problems (right hand corner in Explore view). Can you post the generated query here?

@saurabh1-singh
Copy link
Author

saurabh1-singh commented Dec 25, 2019

@villebro i did look at the query generated here is the diff

  • In the chart which shows error test_c_1, the query generated is as follows
    SELECT user_id AS user_id FROM (select user_id, score FROM table_1) AS expr_qry WHERE score_1 IN (700) AND score_2 IN (800) AND ((score >= '700' and score <= '800')) LIMIT 1000;

  • While in the second chart its
    SELECT user_id AS report_id, score AS score FROM table_1 WHERE ((score >= '700' and score <= '800')) LIMIT 250;

As you can see here what i am trying to point out using a view on the datasource makes it fill the value in the template as well as apply the filter, while using the table directly as datasource does not add extra filter

@saurabh1-singh
Copy link
Author

@villebro @mistercrunch can you guys help

@villebro
Copy link
Member

villebro commented Dec 27, 2019

@saurabh1-singh thanks for the additional context. If I understand what you've done, you're doing something pretty clever with the filter box, for which it hasn't really been designed. Or rather, the problem isn't so much the filter box itself, but the fact that the filter_values function you're calling is referencing columns that are not available in your datasource. I think it might be possible to leave any columns that aren't present in the datasource from the additional filters generated by the function. Let me think about this for a second.

Ultimately though, I think you're actually looking for something similar to what's discussed in #8452 , i.e. a component that makes it possible to define more fine grained filtering than is currently offered by existing components. Am I correct?

@saurabh1-singh
Copy link
Author

@villebro Yes you can say that its a hack for something similar to #8452 . Do you know about when can we expect the work to be done for #8452

@stale
Copy link

stale bot commented Mar 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Mar 2, 2020
@stale stale bot closed this as completed Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
!deprecated-label:bug Deprecated label - Use #bug instead inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

2 participants