I have been looking at the latest version of beanquery as well as messages here and as far as I understand, the only currently available beanquery document is quite out of date with the new features.
Just want to double check my understanding
The documentation says, that
since we have a single table of data, we replace the table name in FROM by a filtering expression which applies over transactions, and the WHERE clause applies to data pulled from the resulting list of postings:
SELECT <target1>, <target2>, …
FROM <entry-filter-expression>
WHERE <posting-filter-expression>;
Both filtering expressions are optional. If no filtering expressions are provided, all postings will be enumerated over. Note that since the transactions are always filtered in date order, the results will be processed and returned in this order by default.
As far as I can see, there are more than one tables available now (not only postings)
beanquery> .tables
accounts
balances
commodities
documents
entries
events
notes
postings
prices
transactions
Now the FROM statement needs to contain table, but preceded by #
e.g.
select date, narration from #transactions
If FROM is omitted, then it is assumed to be FROM #postings
Question: Is this correct?
posting has also all the transaction information, but it is called entry there
beanquery> .describe postings
table postings:
id (str)
type (str)
filename (str)
lineno (int)
date (date)
year (int)
month (int)
day (int)
flag (str)
payee (str)
narration (str)
description (str)
tags (set)
links (set)
meta (dict)
location (str)
posting_flag (str)
account (str)
other_accounts (set)
number (decimal)
currency (str)
cost_number (decimal)
cost_currency (str)
cost_date (date)
cost_label (str)
position (position)
price (amount)
weight (amount)
balance (inventory)
entry (transaction)
beanquery> .describe transactions
table transactions:
meta (metadata)
date (date)
flag (str)
payee (str)
narration (str)
tags (frozenset)
links (frozenset)
beanquery>
So,
select date, account, narration
Gives the same result as
select entry.date, account, entry.narration
Question: why is it done like this? What is the reason to have transaction information (e.g. date ) both in posting as well as in posting.entry?
So far the only place I use it is to access transaction meta as an opposite to posting meta
select date, account, narration, entry.meta as transaction_meta, meta as posting_meta
Question: is it correct, that it is still not possible to create queries, which join tables with each other like in traditional SQL?
Say for every posting I want to list an account as well as the date the account was open.
select #postings.account, #accounts.open where #postings.account = #accounts.account
> So,
>
> select date, account, narration
>
> Gives the same result as
>
> select entry.date, account, entry.narration
>
> Question: why is it done like this? What is the reason to have
> transaction information (e.g. date ) both in posting as well as in
> posting.entry?
Just backward compatibility. The old way of doing things will be
deprecate and eventually removed to make the data model more consistent
and "orthogonal". However, the capability of accessing fields of
structured types in beanquery has only beed recently (compared to how
much time I can dedicate to the project) introduced, and before starting
to emit deprecation warnings I want to have some documentation in place,
and I haven't had time to work on the documentation. Thus for now we
live with the duplication.
--
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 beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/b5494278-ebe9-4033-918c-c2fa93060ebdn%40googlegroups.com.