hi I am running the following query but the count ...
# troubleshooting
s
hi I am running the following query but the count aggregation gives the total number of rows for each channel rather than the number of rows for each channel with eventnumber = 2.Can someone help me debug this SELECT "channel" AS "Group_0", COUNT(CASE WHEN "eventnumber" = 2 THEN 1 END ) AS "Case_Output" FROM testsignupinfo3 WHERE "eventtime" BETWEEN CAST('2024-07-01 00:00' AS TIMESTAMP) AND CAST('2024-07-31 23:59' AS TIMESTAMP) GROUP BY channel;
y
Null handling is currently disabled by default and with no null handling the
COUNT
aggregation function will also include null values (which is what the
CASE WHEN
function returns when no condition is met). If you run the same query with the query option
SET enableNullHandling = true;
, you should see the expected result. Alternatively, you can use a filtered aggregate like
COUNT(eventNumber) FILTER(WHERE eventNumber = 2)
.
s
Hey thanks Yash! setting the above query option worked for me. can i enable null handling in the setup?(somewhere in the broker or server conf) or should i set it each time i run the query
y
Glad that worked! We recently added a broker level config to enable null handling for all queries by default but that'll only be included in the upcoming 1.3.0 release. You can check the null handling related docs here for more details too - https://docs.pinot.apache.org/developers/advanced/null-value-support.
s
ok thank you...
i am actually running a hive query in pinot.Do you suggest rewritting the entire query or can i run the same query in pinot.Will there be any performance difference in both cases.
y
I'm not sure I understand your question exactly - are you asking if the query that you've pasted above needs to be rewritten to be more performant in Pinot?
s
yes.
y
I think a filtered aggregate might be worth trying instead -
COUNT(*) FILTER(WHERE eventnumber = 2)