-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Description
Underlying query fails with ArithmeticException when opening Datasources tab in Druid console.
Affected Version
0.20.0
Description
The error message looks like this:

The underlying query looks like this:
SELECT
datasource,
COUNT(*) FILTER (WHERE (is_published = 1 AND is_overshadowed = 0) OR is_realtime = 1) AS num_segments,
COUNT(*) FILTER (WHERE is_available = 1 AND ((is_published = 1 AND is_overshadowed = 0) OR is_realtime = 1)) AS num_available_segments,
COUNT(*) FILTER (WHERE is_published = 1 AND is_overshadowed = 0 AND is_available = 0) AS num_segments_to_load,
COUNT(*) FILTER (WHERE is_available = 1 AND NOT ((is_published = 1 AND is_overshadowed = 0) OR is_realtime = 1)) AS num_segments_to_drop,
SUM("size") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0)) AS total_data_size,
SUM("size" * "num_replicas") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0)) AS replicated_size,
MIN("size") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0)) AS min_segment_size,
(
SUM("size") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0)) /
COUNT(*) FILTER (WHERE (is_published = 1 AND is_overshadowed = 0))
) AS avg_segment_size,
MAX("size") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0)) AS max_segment_size,
SUM("num_rows") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0) OR is_realtime = 1) AS total_rows,
(
SUM("size") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0)) /
SUM("num_rows") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0))
) AS avg_row_size
FROM sys.segments
GROUP BY 1
and it fails because a divider (in my case SUM("num_rows") FILTER (WHERE (is_published = 1 AND is_overshadowed = 0))) is 0.
Here is what I see when I remove 2 problematic metrics from the query:

Reactions are currently unavailable