Udit Sharma
07/24/2024, 6:53 AMMaytas Monsereenusorn
07/24/2024, 7:33 AM{
"queryType": "groupBy",
"dataSource": "your_data_source",
"intervals": [
"2023-01-01/2023-12-31"
],
"granularity": "all",
"dimensions": [
"your_field"
],
"aggregations": [
{
"type": "count",
"name": "count"
}
]
}Udit Sharma
07/24/2024, 7:36 AMMaytas Monsereenusorn
07/24/2024, 7:37 AMMaytas Monsereenusorn
07/24/2024, 7:37 AMUdit Sharma
07/24/2024, 7:39 AMcount(unique (store)) by city where status=open something like this.Maytas Monsereenusorn
07/24/2024, 7:42 AMMaytas Monsereenusorn
07/24/2024, 7:42 AMMaytas Monsereenusorn
07/24/2024, 7:42 AMUdit Sharma
07/24/2024, 7:44 AMMaytas Monsereenusorn
07/24/2024, 7:55 AMUdit Sharma
07/24/2024, 8:09 AMLaksh Singla
07/24/2024, 12:55 PMSELECT COUNT(DISTINCT col) FROM tbl (exact results)
in Druid, and see the native plan, you’d see that it gets planned as a group by query. That’s the Druid’s way of saying that we need to group by the rows, and count the number of results returned.
That abstraction is hidden from the user because SQL is a declarative language. You won’t see that we are fetching the columns, however we do fetch that, and Druid’s group by query is a way to tell the engine what exactly it needs to do. I suppose count distinct in other databases is done in a similar fashion using hashing+sorting.
TLDR; You need to group by to get a distinct count, and there’s no other alternative that I know can do that for you if you need exact counts. Datasketches work without actual values because they are probablistic datastructures, and store a lot of bit vectors, and not the actual values.Udit Sharma
07/24/2024, 1:43 PMJon
07/24/2024, 4:24 PM