chrisociepa opened a new issue #10707:
URL: https://github.com/apache/druid/issues/10707


   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](https://user-images.githubusercontent.com/34248815/103084186-b2d08b80-45de-11eb-8a3a-e6fc22a3aef2.png)
   
   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](https://user-images.githubusercontent.com/34248815/103084578-a00a8680-45df-11eb-9a7a-36edd1a64ae4.png)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to