On 19/11/2022 19:42, Martin Blais wrote:
On Sat, Nov 19, 2022 at 4:12 AM Peter <[email protected] <mailto:[email protected]>> wrote:

    I'd like to fetch the sum (per account) of the amount of money I
    sent from my checking account to any account during the year. The
    goal is to compute the average outflow per month to get a better
    understanding of the cashflow.

    I tired:

    SELECT account, other_accounts, sum(units(position)) WHERE account ~
    "Assets:Cash:Checking" group by account, other_accounts

    or

    SELECT account, other_accounts, units(sum(position)) WHERE account ~
    "Assets:Cash:Checking" group by account, other_accounts

    and variations of that. Each query failed by telling me

     > TypeError: unhashable type: 'list'

    I guess, there's a problem calculating a hash or so, but I don't
    know. Tried to search in this group, but I didn't find anything
    related that helped (I'm pretty sure I used the wrong search term, tbh).

    How do I get the summarized outflow from the checking account to any
    other account using bean-query?


This is a bug introduced in ca24621e377130fa4763812c0b8ebb8c62ebb9b0
Daniele: are you okay with rolling this back?
My version of "hashable" was more lenient actually, and I think would work in this case. For this purpose we don't actually care much about a proper definition of hashable because the stream of data is frozen in time. I don't even remember why I made a check. Might have been that computing a hash of an inventory isn't useful; alternatively we could just allow it and make Inventory hashable... and remove the check altogether.

From memory, without looking at the code, the columns in the "group by" clause need to be hashable because "group by" is implemented with a Python dictionary.

An exception would have been raised if the check would let the list pass. Indeed, it seems that the reported exception is from the code in beancount v2 and not from the code in beanquery.

The fix is to return other_accounts as a tuple and not as a list.

I'll look into this.

Cheers,
Dan

--
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/75ff42dc-2d07-70fa-af88-e7debafd6fe9%40grinta.net.

Reply via email to