Skip to content

[Jinja] {{from_dttm}} and {{to_dttm}} variables not working as expected #21793

@phongvu99

Description

@phongvu99

Description: Jinja Template {{from_dttm}} and {{to_dttm}} variables not working in SQL queries.

How to reproduce the bug

  1. Go to 'SQL Lab'
  2. Write a query containing either the {{from_dttm}} or {{to_dttm}} variables
  3. Run the query
  4. See the error

Expected results

The results filtered by the date - From A TO B

Actual results

Parameter error
Failed to execute query '1314' - 'SELECT *
FROM lorem_ipsum.Dim_Lorem_Ipsum
WHERE (
  {% if from_dttm is not none %}
      dttm_col > {{ from_dttm }} AND
  {% endif %}
  {% if to_dttm is not none %}
      dttm_col < {{ to_dttm }} AND
  {% endif %}
  true
)': The following parameters in your query are undefined: "from_dttm", "to_dttm". 
 Please check your template parameters for syntax errors and make sure they match across your SQL query and Set Parameters. Then, try running your query again.

Screenshots

Superset Jinja Variables Issue

Environment

(please complete the following information):

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

#19619 The issue first discussion, but no solution so far

Metadata

Metadata

Assignees

No one assigned

    Labels

    #bugBug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions