1247663186 opened a new issue, #35996:
URL: https://github.com/apache/superset/issues/35996
### Bug description
**Description**
After upgrading from Superset 2.1.0 to 6.0.0-rc2 and importing all assets
(dashboards, charts, datasets), we've observed an issue where a Bar Chart
displays correctly on the dashboard, but throws a syntax error when opened in
the "Edit chart" view. This prevents any modifications to the chart.
The root cause appears to be an inconsistency in the SQL query generated for
the same chart in these two different contexts.
**Steps to Reproduce**
1. Upgrade a Superset instance from version 2.1.0 to 6.0.0-rc2.
2. Import dashboards, charts, and datasets that were created in the older
version.
3. Navigate to a dashboard containing a Bar Chart connected to a ClickHouse
database.
4. Observe that the chart loads and displays data correctly on the dashboard.
5. Click the kebab menu (three dots) on the chart and select "Edit chart".
6. On the Chart Editor page, a syntax error is reported, and the chart fails
to load.
**Expected Behavior**
The chart should load without errors in the Chart Editor, using the same
valid query that is successfully executed on the dashboard view.
**Actual Behavior**
The chart works on the dashboard, but fails in the editor. Inspecting the
"View query" reveals that different SQL is generated for the chart in each view.
Query on Dashboard View (Working correctly)
This query is identical to the one used in version 2.1.0 and works as
expected.
```
SELECT
toStartOfDay(toDateTime(event_date)) AS __timestamp,
event AS event,
SUM(abs(profit)) AS "SUM(abs(profit))"
FROM goldeneye_roas.etl_iap_detail_dailyreport
WHERE
event_date >= toDate('2025-10-29')
AND event_date < toDate('2025-11-05')
AND (event NOT IN ('CANCEL', 'DOWNGRADE', 'RENEW_FAILED'))
GROUP BY
event,
toStartOfDay(toDateTime(event_date))
ORDER BY
"SUM(abs(profit))" DESC
LIMIT 10000;
```
Query in Chart Editor View (Causing error)
This query is generated only in the Chart Editor and appears to be
syntactically different, causing the error. The most notable difference is the
alias for the time column (event_date instead of __timestamp).
```
SELECT
toStartOfDay(toDateTime(event_date)) AS event_date,
event AS event,
SUM(abs(profit)) AS "SUM(abs(profit))"
FROM goldeneye_roas.etl_iap_detail_dailyreport
WHERE
(
NOT (
event IN ('CANCEL', 'DOWNGRADE', 'RENEW_FAILED')
)
)
AND event_date >= toDate('2025-10-29')
AND event_date < toDate('2025-11-05')
GROUP BY
toStartOfDay(toDateTime(event_date)),
event
ORDER BY
"SUM(abs(profit))" DESC
LIMIT 10000;
```
**Conclusion/Hypothesis**
It seems there might be a change or regression in how SQL queries are
processed or constructed within the Chart Editor context in version 6.0.0-rc2,
which differs from the logic used in the Dashboard view.
**Environment**
Superset Version: 6.0.0-rc2 (Upgraded from 2.1.0)
Database Engine: ClickHouse
OS: Ubuntu 22.04
Browser: Chrome
**Additional Context (Attachments)**
_Screenshot 1_: The correct SQL query as seen from the "View query" modal on
the Dashboard.
<img width="97" height="63" alt="Image"
src="https://github.com/user-attachments/assets/4d5642c2-5948-437f-94c7-439285309ba1"
/>
_Screenshot 2_: The incorrect SQL query that causes the error, as seen from
the "View query" modal in the Chart Editor.
<img width="109" height="67" alt="Image"
src="https://github.com/user-attachments/assets/43d7fff1-c7fc-41e9-8d84-8e032f7a4810"
/>
### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
3.9
### Node version
16
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [x] 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]