Slackbot
03/02/2023, 2:00 PMJohn Kowtko
03/02/2023, 4:21 PMhaving SUM("mt_attach_attempts")<>0
?Olivier Chautard
03/02/2023, 4:43 PMHAVING "kpi_case1" <> 0 and it works ; but also filters results with 0 (not only NULL)Luiz Augusto
03/02/2023, 4:58 PMsafe_divide(SUM("mt_attach_failures")*1.0, SUM("mt_attach_attempts"))
safe_divide(x,y) returns the division of x by y if y is not equal to 0. In case y is 0 it returns 0 or null if druid.generic.useDefaultValueForNull=false
https://druid.apache.org/docs/latest/misc/math-expr.html
maybe it wont work as it’s an aggregation, but let’s seeJohn Kowtko
03/02/2023, 9:58 PMhaving safe_divide(SUM("mt_attach_failures")*1.0, SUM("mt_attach_attempts")) is not null
Oliver, a correction to my having clause (I can't update my post above), would check both numerator and denominator, e.g.:
having SUM("mt_attach_attempts")<>0 and SUM("mt_attach_failures")<>0
that should logically check the same thing as your CASE statement.Olivier Chautard
03/03/2023, 8:53 AM(Case When SUM("mt_attach_attempts")<>0 THEN (CAST(SUM("mt_attach_failures") AS DOUBLE)/CAST(SUM("mt_attach_attempts") AS DOUBLE)) ELSE 'NaN' END) AS "kpi_case1", and I adapted the filter HAVING "kpi_case1" IS NOT NULL AND CAST("kpi_case1" AS varchar) <> 'NaN' . And now it works for me. 🙂Gian Merlino
03/07/2023, 2:25 PMdruid.generic.useDefaultValueForNull = false in druid's server propertiesGian Merlino
03/07/2023, 2:25 PM