The problem with your query is a combination of things: - You're making an aggregate query, as per the presence of sum() - You're not using an explicit GROUP BY clause, so it selects all the non-aggregate columns for you (year, month, balance). balance is of type Inventory. All non-aggregate types must be hashable (though I could relax that to make them required comparable, with a little cost).
If you use last(balance) instead of balance, that would just work (group by year, month, only, which is likely what you wanted anyway). Granted: It should not fail with an exception like this (but this needs a full rewrite, see other emails for my thoughts on this). On Thu, Nov 1, 2018 at 3:19 PM Ethan <[email protected]> wrote: > That's fantastic, thank you very much. I was able to get what (grouped by > month) I wanted using `SELECT year(date), month(date), > last(cost(balance))`. I wasn't able to use `SELECT year, month, > sum(cost(position)), balance WHERE date > 2018-10-20`. When I try I get > this exception: > > Traceback (most recent call last): > File > "/nix/store/nrl0l79a48924xb0897ap572xf29ciir-python3-3.6.6/lib/python3.6/cmd.py", > line 214, in onecmd > func = getattr(self, 'do_' + cmd) > AttributeError: 'QueryShell' object has no attribute 'do_SELECT' > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File > "/nix/store/fp1w3x8kapd6bj0d2ay2q5ghpwjhzl1h-python3.6-beancount-2.1.2/lib/python3.6/site-packages/beancount/query/shell.py", > line 270, in run_parser > self.dispatch(statement) > File > "/nix/store/fp1w3x8kapd6bj0d2ay2q5ghpwjhzl1h-python3.6-beancount-2.1.2/lib/python3.6/site-packages/beancount/query/shell.py", > line 250, in dispatch > return method(statement) > File > "/nix/store/hi4vx0wnnllvlvfbd3hdblpxhdmlcjjr-fava-1.7/lib/python3.6/site-packages/fava/core/query_shell.py", > line 89, in on_Select > self.options_map) > File > "/nix/store/fp1w3x8kapd6bj0d2ay2q5ghpwjhzl1h-python3.6-beancount-2.1.2/lib/python3.6/site-packages/beancount/query/query_execute.py", > line 327, in execute_query > store = agg_store[row_key] > TypeError: unhashable type: 'Inventory' > > I'm not sure if that's expected or not -- should I file a bug? > > Ethan > > On Thu, Nov 1, 2018 at 3:01 PM Stefano Zacchiroli <[email protected]> wrote: > >> On Thu, Nov 01, 2018 at 11:49:36AM -0700, [email protected] >> wrote: >> > Is there a bean-query mechanism for doing accumulation or "running >> count" >> > operations? I could "roll my own" using a subquery but I see from the >> > documentation that sub-selects aren't supported. >> >> You have the balance "column", as in: >> >> SELECT balance WHERE account ~ '^(Liabilities|Assets)' ORDER BY date; >> >> See: "The “balance” Column" in the BQL documentation here: >> >> >> https://docs.google.com/document/d/1s0GOZMcrKKCLlP29MD7kHO4L88evrwWdIO0p4EwRBE0/ >> >> It's not a fully generic running count, but AFAICT is what is used by >> the BALANCES shorthand query which you cited as initial example. >> >> Cheers >> -- >> Stefano Zacchiroli . [email protected] . upsilon.cc/zack . . o . . . o . o >> Computer Science Professor . CTO Software Heritage . . . . . o . . . o o >> Former Debian Project Leader & OSI Board Director . . . o o o . . . o . >> « the first rule of tautology club is the first rule of tautology club » >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Beancount" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/beancount/dtOply6B8xQ/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/beancount/20181101190147.75d3a224xwe7gi2d%40upsilon.cc >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > 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 post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beancount/CAOJ%2BOb07re2AcWdYxQqUOTBkiJKm8kX1CpfprifFyF3Fq%2BPUaA%40mail.gmail.com > <https://groups.google.com/d/msgid/beancount/CAOJ%2BOb07re2AcWdYxQqUOTBkiJKm8kX1CpfprifFyF3Fq%2BPUaA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhNwjYNXXszXT7%3DkzpQktFZSbTGnTcpTraDVG_H%3D0WUFXg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
