-
Notifications
You must be signed in to change notification settings - Fork 25.8k
COUNT DISTINCT for 0 matching documents return NULL #50013
Copy link
Copy link
Closed
Labels
Description
When #44745 has been introduced as a way of aggregations (SUM, MAX, AVG etc) dealing with a lack of documents matching a query and, implicitly, dealing with NULLs the case of COUNT(DISTINCT) (that uses a cardinality aggregation behind the scene) has been approached as well.
But, this introduced the issue of returning a NULL for COUNT(DISTINCT) where there are no matching documents. For example SELECT COUNT(DISTINCT languages) FROM test_emp WHERE languages > 100 returns NULL, whereas it should return 0 since there are no documents matching the condition languages > 100.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.