Skip to content

What's the issue with sumDistinct ? #6539

@George3d6

Description

@George3d6

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions