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 templating not working (1.2.0-rc2) requires undocumented config #15283

Closed
3 tasks done
squalou opened this issue Jun 21, 2021 · 7 comments
Closed
3 tasks done

jinja templating not working (1.2.0-rc2) requires undocumented config #15283

squalou opened this issue Jun 21, 2021 · 7 comments
Labels
#bug Bug report global:jinja Related to Jinja templating

Comments

@squalou
Copy link
Contributor

squalou commented Jun 21, 2021

Expected results

Following documentation, running for instance this query should work (from sql lab)

SELECT  *
FROM mytable
WHERE username = '{{ current_username() }}'

should work and return results.

Actual results

{{ current_username() }} is not interpreted at all, is considered as a String. Hence the result does not work.

Note that '{{ url_param('myparam') }}' does not work either

looks like no templating interpretation is done.

Used to work fine in 0.38

Does not work in 1.2.0-RC2

I don't know where to look for detailed executions logs. I had a look un query table of superset schema, query was not traced interpreted there but maybe it's the expected result.

Screenshots

If applicable, add screenshots to help explain your problem.

How to reproduce the bug

  1. Go to 'SQL Lab'
  2. Enter a query using Jinja templating
  3. See issue

Environment

(please complete the following information):

  • superset version: Superset 1.2.0 (1.2.0-RC2 actually)
  • python version: Python 3.7.9
  • node.js version: not present in container

Checklist

Make sure to follow these steps 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.

@squalou squalou added the #bug Bug report label Jun 21, 2021
@squalou squalou changed the title jinja tempalting not working at all (1.2.0-rc2) jinja templating not working at all (1.2.0-rc2) Jun 21, 2021
@squalou
Copy link
Contributor Author

squalou commented Jun 21, 2021

Another example ... disclaimer : I'm not certain it was supposed to work, using the templating in the 'select'.

I can't find any other 'visually' self-explaining screenshot of the issue.

image

@squalou
Copy link
Contributor Author

squalou commented Jun 21, 2021

I've found this :

#12487

but nowhere in the documentation I can find how to enable

@squalou squalou changed the title jinja templating not working at all (1.2.0-rc2) jinja templating not working (1.2.0-rc2) requires undocumented config Jun 21, 2021
@squalou
Copy link
Contributor Author

squalou commented Jun 21, 2021

for the records, this works in superset_config.py

It should really be added here : https://superset.apache.org/docs/installation/sql-templating

FEATURE_FLAGS = {
    "ENABLE_TEMPLATE_PROCESSING": True
}

BUT it still doesn't work in SQL LAB. It works when used elsewhere

@maltoze
Copy link
Contributor

maltoze commented Jun 22, 2021

Hope this can help. #15246

@zhaoyongjie zhaoyongjie added the global:jinja Related to Jinja templating label Jun 24, 2021
@NikosSpanos
Copy link

for the records, this works in superset_config.py

It should really be added here : https://superset.apache.org/docs/installation/sql-templating

FEATURE_FLAGS = {
    "ENABLE_TEMPLATE_PROCESSING": True
}

BUT it still doesn't work in SQL LAB. It works when used elsewhere

Thanks a lot for this post @squalou ...Firstly, I added the ENABLE_TEMPLATE_PROCESSING in the config.py file which didn't help at all. Then I saw your post and added the same property on the superset_config.py and made the Jinja templating available through Virtual SQL. You may want to check this video on YouTube and see how you can use the templating and dunamic filtering with Filter Boxes.

Hope it helps. Kudos!!

@rusackas
Copy link
Member

rusackas commented Jan 6, 2023

Between the PR that appears to resolve the issue, the other help docs in the thread, and the relatively long silence on this thread, I'll go ahead and call this one case-closed. If there are indeed clarifications that need to be made in the documentation, would anyone be willing to open up a small PR and help add some clarity? It would be much appreciated!

@rusackas rusackas closed this as completed Jan 6, 2023
@1sarah
Copy link

1sarah commented Jun 25, 2024

Hello everyone ..I have question concerning jinja template (url_param) i have a an sql(and a dataset too )that have populated
but when a request is made from the frontend am getting missing the right paranthesesis.Any help will be kindly appreciated

#passing params from portal to dashboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report global:jinja Related to Jinja templating
Projects
None yet
Development

No branches or pull requests

6 participants