On Sat, Sep 29, 2018 at 7:12 PM Martin Blais <[email protected]> wrote:
> I don't feel that the kinds of complex joins/conditions that Prolog > provides are really useful for the kinds of info we need to export out of > Beancount, but I'm definitely not very familiar with these systems (my > Prolog experiment extends to have read just about halfway through the > Reasoned Schemer and a few papers here and there). AFAIK we mostly really > just need a single projection + filter / aggregation type of query. > > And subqueries and windows sometimes. At the very least scalar subqueries. Although, non-scalar subqueries would be awesome (at which point they're really joins). > Nothing should prevent you from exploring and filling up a database of > rules or a tuple space with the contents of a Beancount ledger though, and > experiment with that. > > Right, I have a script (using ideas from the sqlite export code) that loads beancount entries into a postgres database on which I can issue as complex a query as I want. But for that, I had to write a load script, define a bunch of composite types & python UDFs that can handle the datatypes in beancount. This is rather incomplete at the moment though, but fairly functional (although maybe not performant). This can be extended further using postgres external tables / FDW. Anyway, even though this gives me access to the full power of postgres' SQL compliance, the queries are complex (involving views with joins just like in sqlite) and they lose the nuanced difference of "entry" vs "position" in beancount. I'm sure there's a middle ground solution lurking somewhere. I'm not really familiar with ibis to comment on that. > > On Sat, Sep 29, 2018 at 1:18 PM Daniele Nicolodi <[email protected]> > wrote: > >> I haven't thought much about this, but wouldn't RDF and SPARQL also be >> goo matches for this task? I believe rdflib provides all required >> building blocks. I'm not sure if SPARQL is a suitable query language, >> though. >> >> On 29/09/2018 10:58, Martin Blais wrote: >> > This whole SQL prototype needs to get rewritten at some point. >> > It really is just a quickly put together, poorly tested prototype. >> > (I've started to fiddle a tiny litlte bit with Project Ibis >> > (https://github.com/ibis-project/ibis) and maybe implementing a SQL FE >> > to this and a simple in-memory BE could leverage its type system and >> > provide a more robust SQL-like implementation.) >> > >> > >> > On Sat, Sep 29, 2018 at 9:52 AM Stefano Zacchiroli <[email protected]> >> wrote: >> > >> > On Sat, Sep 29, 2018 at 06:33:48AM -0700, >> > [email protected] <mailto:[email protected]> >> wrote: >> > > Did you already try : >> > > STR(ANY_META('trip')) != null ?? >> > >> > Oh, I didn't know about null in BQL. So the following works (which >> is >> > probably what you meant above): >> > >> > ANY_META('trip') != null >> > >> > and is indeed quite nice. >> > >> > Interpreting null values as False in boolean context would still be >> a >> > nice to have, but it's definitely not more important than that. >> > >> > Thanks for the tip! >> > >> > Cheers >> > -- >> > Stefano Zacchiroli . [email protected] . upsilon.cc/zack >> > <http://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 the Google >> > Groups "Beancount" group. >> > To unsubscribe from this group and stop receiving emails from it, >> > send an email to [email protected] >> > <mailto:beancount%[email protected]>. >> > To post to this group, send email to [email protected] >> > <mailto:[email protected]>. >> > To view this discussion on the web visit >> > >> https://groups.google.com/d/msgid/beancount/20180929135225.v26knfs3lty5zxnv%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] >> > <mailto:[email protected]>. >> > To post to this group, send email to [email protected] >> > <mailto:[email protected]>. >> > To view this discussion on the web visit >> > >> https://groups.google.com/d/msgid/beancount/CAK21%2BhMsbLf3ZxDiSdCasgZG4j8kf3ohSYHpZ7-_QbS3_PtxLw%40mail.gmail.com >> > < >> https://groups.google.com/d/msgid/beancount/CAK21%2BhMsbLf3ZxDiSdCasgZG4j8kf3ohSYHpZ7-_QbS3_PtxLw%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/4e3eec41-29fd-e958-1c0d-f94104c54b5e%40grinta.net >> . >> 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%2BhPgdVfprUr4kLHoeFML_MZOSbjsDp_nA42cKV14NvvQ1w%40mail.gmail.com > <https://groups.google.com/d/msgid/beancount/CAK21%2BhPgdVfprUr4kLHoeFML_MZOSbjsDp_nA42cKV14NvvQ1w%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/CAAY9sD8WsBbcGA9BiZo_V%2Bof0kCNSSCJJm%3D_J__hAcbL2SZreQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
