Fork me on GitHub
#datalog
<
2020-08-06
>
dregre21:08:22

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.

Vishal Gautam21:08:20

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

refset21:08:26

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!

quoll00:08:58

Cool. Asami also does this (it can be turned off), although there isn’t any reporting of which path it uses.

quoll00:08:41

I’m also curious about what you mean by “Rules”. Is this queries built from queries, as Datomic does, or is it about creating new database operations (like assertions) based on existing data, as per Datalog Horn clauses?

dregre13:08:59

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

👍 3
dregre17:08:51

@U899JBRPF 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?

refset18:08:34

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

dregre18:08:07

Does Crux do notand not-join?

dregre18:08:39

Thanks a lot 🙂

🙏 3