New issue 218: Ignore division by zero in queries
https://bitbucket.org/blais/beancount/issues/218/ignore-division-by-zero-in-queries
Jakob Schnitzer:
In Fava, the holdings report is generated using the BQL. It would be nice if we
could use the following query. However, this query will fail (unless one has no
closed holdings), as the average_cost column will be "0/0" or "x/0".
SELECT
units(sum(position)) as units,
number(only(first(cost_currency),
cost(sum(position))))/number(only(first(currency), units(sum(position)))) as
average_cost,
cost(sum(position)) as book_value,
value(sum(position)) as market_value
WHERE account_sortkey(account) ~ "^[01]"
GROUP BY currency, cost_currency
ORDER BY currency, cost_currency
See also https://github.com/beancount/fava/issues/645.
> It could spit a warning and ignore that row? Is that reasonable?
I think that just setting the failing table cell to be empty would be ideal.
Right now there is no way to run a query where a single cell might contain an
invalid decimal operation (and there is now way to prevent the invalid
operation as far as I can see). The rest of the offending row would still be
useful though.
[If you dislike the idea of silently ignoring such errors, another possibility
to address this would be to add some query function that silently swallows all
exceptions, like `try(0.0/0.0)`]
--
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/20180221134026.28263.24809%40celery-worker-110.ash1.bb-inf.net.
For more options, visit https://groups.google.com/d/optout.