Repository navigation
[6.0.0-RC2] >>Group remaining as "Others"<< generates an incorrect SQL Query #35815
Copy link
Copy link
Closed
Closed
Copy link
Labels
viz:charts:barRelated to the Bar chartRelated to the Bar chart
Description
Bug description
If I create a bar chart with the option Group remaining as "Others" enabled, the selected filters no longer apply due to an incorrect SQL query.
This is the SQL code with the option disabled:
SELECT
DATE_TRUNC(creation_date, DAY) AS creation_date,
destination_table_id AS destination_table_id,
sum(total_costs) AS SUM_total_costs__c069f
FROM project_id.stg_bigquery_metadata.stg_bigquery_metadata__costs_per_table_per_user
JOIN (
SELECT
destination_table_id AS destination_table_id__,
sum(total_costs) AS mme_inner__
FROM project_id.stg_bigquery_metadata.stg_bigquery_metadata__costs_per_table_per_user
WHERE
creation_date >= CAST('2025-09-25' AS DATE)
AND creation_date < CAST('2025-10-24' AS DATE)
GROUP BY
destination_table_id__
ORDER BY
sum(total_costs) DESC
LIMIT 10
) AS series_limit
ON destination_table_id = destination_table_id__
WHERE
creation_date >= CAST('2025-09-25' AS DATE)
AND creation_date < CAST('2025-10-24' AS DATE)
GROUP BY
creation_date,
destination_table_id
ORDER BY
SUM_total_costs__c069f DESC
LIMIT 10000
If I enable the option, the following code is generated:
SELECT
DATE_TRUNC(creation_date, DAY) AS creation_date,
CASE
WHEN (
NOT series_limit.destination_table_id__ IS NULL
)
THEN destination_table_id
ELSE 'Others'
END AS destination_table_id,
sum(total_costs) AS SUM_total_costs__c069f
FROM project_id.stg_bigquery_metadata.stg_bigquery_metadata__costs_per_table_per_user
LEFT OUTER JOIN (
SELECT
destination_table_id AS destination_table_id__,
sum(total_costs) AS mme_inner__
FROM project_id.stg_bigquery_metadata.stg_bigquery_metadata__costs_per_table_per_user
WHERE
creation_date >= CAST('2025-09-25' AS DATE)
AND creation_date < CAST('2025-10-24' AS DATE)
GROUP BY
destination_table_id__
ORDER BY
sum(total_costs) DESC
LIMIT 10
) AS series_limit
ON destination_table_id = destination_table_id__
GROUP BY
creation_date,
CASE
WHEN (
NOT series_limit.destination_table_id__ IS NULL
)
THEN destination_table_id
ELSE 'Others'
END
The second (= outer) WHERE clause is missing and therefor the chart is not filtered to the selected time period.
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
I don't know
Node version
I don't know
Browser
Chrome
Additional context
No response
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
viz:charts:barRelated to the Bar chartRelated to the Bar chart
Type
Projects
- StatusShow more project fieldsCherried
Activity
rusackas commentedon Oct 28, 2025
@mistercrunch I think this is a PR you opened, which we saw working on the Pie chart... any reason it shouldn't be available here?
rusackas commentedon Oct 28, 2025
@inazr is this working for you in the Pie chart or does the SQL work there? If it's busted there, we have a bigger problem. If it's only busted for the Bar chart, maybe we take it out or fix forward depending on level of effort.
inazr commentedon Oct 29, 2025
For the Pie chart the threshold is created based on the query results, not in the query itself. Therefor the filter does work correctly.
richardfogaca commentedon Oct 31, 2025
Hello @inazr, thanks for catching this bug. I opened a PR with a fix for this issue: #35937 @rusackas