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.
Thanks everyone! quoll, it’s the former for now — Datomic-style query rules rather than Datalog Horn rules :)
@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?
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
Does Crux do not
and not-join
?
Yep! It's worth a skim through this ns https://github.com/juxt/crux/blob/master/crux-test/test/crux/query_test.clj
Thanks a lot 🙂
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
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!