Bug description
I get an error when using the filter by metric in the Histogram chart.
Apache Druid Error
'errorClass'
This may be triggered by:
Issue 1002 - The database returned an unexpected error.
How to reproduce the bug
- build a histogram chart
- add a metric filter(
having count(*)
) - update the chart to get a view
- You will get an error
Screenshots/recordings
Superset version
4.0.2
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.
- [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [X] 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.
Comment From: dosubot[bot]
I found a similar unsolved discussion regarding an error when filtering a Druid query from the dashboard [1].
The known limitation of the Histogram chart in Superset is that cross filtering is not yet implemented [2].
In Superset version 4.0.2, there were fixes related to metric filtering and general filtering that might be relevant: 1. Fix: Custom SQL filter control (#29260): This fix addresses issues with the custom SQL filter control, which could impact how metrics are filtered. 2. Fix: filters not updating with force update when caching is enabled (#29291): This fix ensures that filters update correctly even when caching is enabled, which could affect metric filtering [3].
The specific SQL syntax or query configurations known to cause issues with Apache Druid in Superset are related to time grain expressions. Deviations from predefined expressions might cause issues [4][5].
For handling metric filters with Apache Druid, ensure that the pydruid
package is installed and the connection string is correctly set up:
pip install pydruid
Connection string format:
druid://<User>:<password>@<Host>:<Port-default-9088>/druid/v2/sql
This setup allows Superset to handle Druid metrics and post-aggregations effectively [6].
To continue talking to Dosu, mention @dosu.
Comment From: rusackas
I was able to get this to work fine on other dbs... seems more like a Druid driver issue? Maybe @betodealmeida will have a clue.
Comment From: rusackas
Also, indeed, it seems Dosu is right about the linked discussion looking rather similar.
Comment From: rusackas
Is anyone still facing this in 4.1.2 or newer? It's been silent for >200 days and is at risk of being closed as stale.
Comment From: rusackas
OK, just went and validated this myself. This is indeed busted.
On the latest master
we at least see a more helpful error:
Indeed, if I add a "GROUP BY" it works just fine.
Comment From: betodealmeida
The problem is that the histogram chart has no aggregations. Without aggregations, you can't have a HAVING
clause — this is not Druid specific, I was able to test reproduce this in BigQuery. Even if you select one or more dimensions it will still fail, since the aggregation is done on the client for some reason.
@mistercrunch do you know why this is done on the client and not in the SQL?
Comment From: mistercrunch
Was community contributed as is. Should really be server-side ... needs 2 passes probably to get min/max, but that's easy now in plugins, probably wasn't easy/possible at the time it was contributed. The best approach is probably to stay in the realm of super-simple SQL, like first phase min/max, second phase CASE WHEN