datalog

dregre 2020-08-06T21:06:22.099200Z

I put this in the #datomic channel but got no love, and so I am wondering whether any old Datalog practitioners may have pearls of wisdom to share: 1. Essentially, I’m looking for suggestions on how to test Datalog rules. My current approach is to load a database with facts, perform different queries on the database using the rules, and to check if the results are as expected. I am wondering whether there are other, better approaches that I may be missing. 2. Likewise, I am looking for a “query explainer” — analogous to EXPLAIN in SQL-land. I’m wondering if any of the Clojure-first Datalog query engines out there that you may be acquainted with have some such functionality. PS: I’m still crawling, not running, with Datomic’s Datalog — so this may be totally on me — but to be honest I’ve found the lack of tools to profile my rules and queries a bit stunning. I’m wondering whether this is just me, whether it’s just a Datomic thing, or whether I’m thinking about it the wrong way.

dregre 2020-08-07T13:53:59.103600Z

Thanks everyone! quoll, it’s the former for now — Datomic-style query rules rather than Datalog Horn rules :)

👍 1
dregre 2020-08-07T17:58:51.103900Z

@taylor.jeremydavid could I for the most part use Crux as a drop-in replacement for Datomic with regard to my query rules? IOW would I have to rewrite them for Crux?

refset 2020-08-07T18:10:34.104100Z

The rule syntax is very similar IIRC, but it ultimately depends on what's inside the rules. Like you might need to write a few extra predicates for Crux to recreate some built-ins that Crux doesn't provide out of the box. Equally for destructuring

dregre 2020-08-07T18:19:07.104300Z

Does Crux do notand not-join?

refset 2020-08-07T18:21:33.104500Z

Yep! It's worth a skim through this ns https://github.com/juxt/crux/blob/master/crux-test/test/crux/query_test.clj

dregre 2020-08-07T18:22:39.104800Z

Thanks a lot 🙂

🙏 1
v 2020-08-06T21:33:20.102Z

with function provided by datomic should do the trick. You can read how it is done in this blog http://jamespw.com/clojure/datomic/testing/2016/09/17/testing-datomic-queries-and-pulls-using-with.html

refset 2020-08-06T21:57:26.102400Z

We built an explainer tool for Crux that shows the layered virtual+physical index structure produced by the query planner: https://github.com/crux-labs/crux-inspector It's a very different query engine to Datomic internally though. For example, Crux doesn't care about user-provided clause ordering and instead always calculates a join order based on attribute cardinalities (and you can see some more info about the calculation if you turn on debug logging for crux.query) I don't have any specific tips for testing individual rules unfortunately - but I'm equally curious to see the suggestions!