The issue lies with count(*) which should never return null.
I just happened to notice it when using APPROX_COUNT_DISTINCT as well (most likely a corner case when generating the query plan).
I see what you’re saying, not really trying to defend the bug
I raised a JIRA for it (DX-86597), so the COUNT expression returns 0 instead of null. The order doesn’t matter, it looks like COUNT will return null either way.