Skip to content

Updating SQL queries in SQL Lab not reflecting in chart instances #31956

Open
@thalmis-zt

Description

@thalmis-zt

Bug description

OBJECTIVE:
Create a chart which can be embedded in an external website. The chart should be filterable by passing filter values as url params.

STEPS FOLLOWED:
Created an sql query in SQL lab with jinja templating to allow custom url params.

SELECT rseti,course_id,state, course_name
FROM course_overview
WHERE state = '{{ url_param("state_value","238") }}' AND course_name <= '{{url_param("course_name","12")}}'

Saved the query and Hit create chart
Image

Named the chart as “Demo Chart” and saved it.
Image

Copied the embed src and pasted in a new tab to view the chart.
Image

Chart is working fine as expected, with the state_value param filter being applied.
Image

Now, suppose I wish to edit the chart at a later point, which is best done by editing the sql query itself.
To do that, I go to Charts menu in Superset UI and click on the desired chart.
Image

In chart Explore page, I select the View in SQL Lab option
Image

I modified the query , to avoid the rseti column ( as below)

SELECT course_id,state, course_name
FROM course_overview
WHERE state = '{{ url_param("state_value","238") }}' AND course_name <= '{{url_param("course_name","12")}}'

Image

Satisfied with the results, I hit Save button. Got a message saying query has been saved.
Now, I go back to the tab where the earlier embed src is used and hit refresh, expecting that the ‘rseti’ column would have been removed from there as well. But, it isnt.

Image

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.10

Node version

18 or greater

Browser

Chrome

Additional context

Superset logs
No errors found. Adding it in case it helps.

2025-01-22 13:04:56,717:DEBUG:superset.sql_parse:Parsing with sqlparse statement: SELECT rseti AS rseti,
superset_app | course_id AS course_id,
superset_app | state AS state,
superset_app | course_name AS course_name
superset_app | FROM
superset_app | (SELECT rseti,
superset_app | course_id,
superset_app | state,
superset_app | course_name
superset_app | FROM course_overview
superset_app | WHERE state = '263'
superset_app | AND course_name <= '12') AS virtual_table
superset_app | LIMIT 1000

"POST
/superset/log/?explode=events HTTP/1.1" 200 1 "http://localhost:8088/superset/explore/p/pP0mYgvz2Jb/?state_value=263&standalone=1&height=400"

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    global:jinjaRelated to Jinja templatingsqllabNamespace | Anything related to the SQL Lab

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions