[storm] Issue with find(), group by, and Single aggregates error

Thomas Hervé thomas at canonical.com
Wed Nov 10 08:02:16 GMT 2010


On 09/11/2010 23:39, Ian Booth wrote:

> result = store.using(xxxx).find(yyyy).group_by(zzzz)
> return result
>
> This however causes an error:
>
> storm FeatureError: Single aggregates aren't supported after a GROUP BY
> clause
>
> So it seems that using a view with navigation links on the table results
> in an attempt to call count() on the resultset from the find() and this
> is failing. Tracing the sql and executing this sql directly against the
> db works just fine and produces the right data. But when using storm to
> try and do the same thing it doesn't work.

Hi Ian,

The problem is that we can't guess which query to run when calling 
count. In the normal scenario, you have a query like that:

SELECT a, b FROM c WHERE x;

Storm generates:

SELECT COUNT(*) FROM c WHERE x;

But when a GROUP BY is involved, this mechanism doesn't work anymore. 
What Storm could do is:

SELECT COUNT(*) FROM (SELECT a, b FROM c GROUP BY a, b) AS tmp_

It's not the default behavior for now. You may be able to simulate it 
using the get_select_expr method of ResultSet, and manually building a 
count.



More information about the storm mailing list