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 templates not working in superset 1.0 rc1 #12487

Closed
lilila opened this issue Jan 13, 2021 · 13 comments
Closed

Jinja templates not working in superset 1.0 rc1 #12487

lilila opened this issue Jan 13, 2021 · 13 comments
Assignees
Labels
global:jinja Related to Jinja templating

Comments

@lilila
Copy link

lilila commented Jan 13, 2021

Queries using Jinja variables are not working anymore in Superset 1.0 rc1.

For instance I have a dataset defined as follows :

{% set title_target = ' "'  + filter_values("title_target", 'Joker')[0] + '" ' %}
{% set title_type =  'title' %}

{% if filter_values('title_target_original')|length > 0 %}
    {% set title_target =  ' "'  + filter_values("title_target_original", 'Joker')[0] + '" ' %}
    {% set title_type =  'title_original' %}
{% endif %}


SELECT {{title_target}} AS title_to_display

I use to work well but now I receive the following error:

Error: (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'%\n set title_target = \' "\' + filter_values("title_target", \'Joker\')[0] + \'" \' \' at line 4')

If I move the Jinja parameters in the "template parameters" section:

Screenshot 2021-01-13 at 08 09 06

I receive the following error:
Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

@lilila lilila added the #bug Bug report label Jan 13, 2021
@junlincc junlincc removed the #bug Bug report label Jan 13, 2021
@junlincc
Copy link
Member

@lilila thanks for reporting, we will get to it asap!

@junlincc junlincc added global:jinja Related to Jinja templating P1 Priority item - Major labels Jan 13, 2021
@villebro
Copy link
Member

Thnks for reporting @lilila , going to work on this now.

@villebro
Copy link
Member

@lilila I'm not able to reproduce the first case - I assume you've enabled the template processing feature flag?

FEATURE_FLAGS = {
    "ENABLE_TEMPLATE_PROCESSING": True,
}

See #11172

@lilila
Copy link
Author

lilila commented Jan 13, 2021

@villebro , No I didn't , works when enabled ! Sorry and thank you

@villebro
Copy link
Member

Great, no worries!

@junlincc junlincc removed the P1 Priority item - Major label Jan 13, 2021
@annibac
Copy link

annibac commented Apr 27, 2021

Just a quick question , how do I include this with Helm?
I tried to add this in values.yaml, but it seems to be ignored :

configOverrides: my_override: | FEATURE_FLAGS = { "ENABLE_TEMPLATE_PROCESSING": True }

When I try to use {{ filter_values("sampling")[0] }} I get the following postgresql error : Postgresql Error : syntax error at or near "{"

@abhiroop93
Copy link

Have the same question, how do I include this with Helm?

@annibac
Copy link

annibac commented Apr 30, 2021

Hello !
I just found a way

In your folder, go to superset > template : there is a "_helpers.tpl" file which contains the superset_config.
Just add at the end:

FEATURE_FLAGS = {
    "ENABLE_TEMPLATE_PROCESSING": True,
}

And this will work. Not sure if this is the best way to do it, but works for me for now.

@abhiroop93
Copy link

Thanks Celine!
There is a slightly better place of putting it, you can just include it in the configOverrides section in values.yaml like below:

configOverrides: {}
  enable_oauth: |
     FEATURE_FLAGS = {
        "ENABLE_TEMPLATE_PROCESSING": True,
     }

@mona-mk
Copy link

mona-mk commented Jul 1, 2021

I think the correct place with docker nowadays is here:
Screenshot 2021-07-01 at 11 27 34

@NikosSpanos
Copy link

@lilila I'm not able to reproduce the first case - I assume you've enabled the template processing feature flag?

FEATURE_FLAGS = {
    "ENABLE_TEMPLATE_PROCESSING": True,
}

See #11172

Should be added on superset_config.py file and NOT on config.py file

@NikosSpanos
Copy link

I think the correct place with docker nowadays is here: Screenshot 2021-07-01 at 11 27 34

This is the way to make it work. Kudos!

@blackmamba-ops
Copy link

@lilila I'm not able to reproduce the first case - I assume you've enabled the template processing feature flag?

FEATURE_FLAGS = {
    "ENABLE_TEMPLATE_PROCESSING": True,
}

See #11172

Should be added on superset_config.py file and NOT on config.py file

Didnt worked for me even after enabling

"ENABLE_TEMPLATE_PROCESSING": True 

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

No branches or pull requests

8 participants