-
Notifications
You must be signed in to change notification settings - Fork 8.3k
What's the issue with sumDistinct ? #6539
Description
I'm trying to do a query along the lines of:
SELECT SUM(DISTINCT( (gb_val, weight).2 )) FROM my_table
But I get exception:
DB::Exception: Unknown function SUMDistinct.
However, the same logic works perfectly well with:
arraySum(arrayMap(lambda(tuple(x), tupleElement(x, 2)), groupUniqArray(tuple(gb_val, weight)))) ... which is slow as ****, presumably due to all the array creation and appending that's going on.
Why is sumDistinct not a valid function in this case ? And is there a fundamental issue that would stop it from being implemented ? Is there a more efficient way to go about this problem ?
In my case the same gb_val always has the same weight, so the distinct is only needed on the gb_val column, ANY could be applied to weight... but I think that's besides the point.