Repository navigation
fix(sql): revert the Custom SQL metric GROUP BY check from #42199 - #46650
Open
DamianPendrak wants to merge 2 commits into
Open
DamianPendrak wants to merge 2 commits into
DamianPendrak wants to merge 2 commits into
Conversation
…ROUP BY (apache#42199) The check added in apache#42199 rejected every Custom SQL metric without an aggregate whenever the query had a GROUP BY. That also blocks valid SQL that worked in 6.1, such as constants ('WIP') and expressions over grouped columns only ((this_week - last_week) / last_week). Remove the check and its error tests, and add a regression test for those cases. has_aggregate() stays in superset/sql/parse.py: other code uses it. Fixes apache#46641 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
…s.pot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks done
1 task done
MikolajBalcerek
approved these changes
Nov 27, 2026
MikolajBalcerek
left a comment
Contributor
There was a problem hiding this comment.
Closing my partial fix in favour of revert to fix all the blocked charts cases :)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46650 +/- ##
==========================================
- Coverage 65.80% 65.79% -0.01%
==========================================
Files 3146 3146
Lines 220020 220012 -8
Branches 52111 52106 -5
==========================================
- Hits 144781 144766 -15
- Misses 71807 71816 +9
+ Partials 3432 3430 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Reverts the check added in #42199, which rejected every Custom SQL metric without an aggregate whenever the query had a GROUP BY.
That check also blocks valid SQL that worked in 6.1, as reported in #46641 (thanks @MikolajBalcerek):
'WIP'next toCOUNT(*), grouped bychannel;(this_week - last_week) / last_weekgrouped byfranchise, this_week, last_week.Every heuristic version of this check risks blocking valid SQL (quoted names, subqueries, dialect rules), while it only improved the error for queries the database rejects anyway. So this removes it; the database's own error applies again, as before #42199. A later follow-up can improve the message for #38913 by adding a hint to the database's GROUP BY error instead of checking in advance.
has_aggregate()stays insuperset/sql/parse.py, since other code uses it. The error tests are removed, and a regression test covers constants and grouped-column expressions.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
'WIP'(plusCOUNT(*)): it runs.franchise,this_week,last_weekwith the metric(this_week - last_week) / last_week: it runs.pytest tests/unit_tests/models/helpers_test.py -k custom_sql_metric.ADDITIONAL INFORMATION