Skip to content

Druid console: ArithmeticException in Datasources tab #10707

@chrisociepa

Description

@chrisociepa

Underlying query fails with ArithmeticException when opening Datasources tab in Druid console.

Affected Version

0.20.0

Description

The error message looks like this:
image

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:
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions