Search Shortcut cmd + k | ctrl + k
mentat

Datomic-compatible Datalog query engine as a DuckDB extension

Maintainer(s): gburd

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.4.4 1.4.5 1.5.5 1.5.6 2.0.0
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL mentat FROM community;
LOAD mentat;

Example

LOAD mentat;
-- Transact a schema and data into the mentat store 'default'. Its datoms are
-- DuckDB tables (schema `mentat`) in the database you have open.
SELECT edn_t('default',
  '[{:db/ident :person/name :db/valueType :db.type/string :db/cardinality :db.cardinality/one}]');
SELECT edn_t('default', '[{:person/name "Alice"} {:person/name "Bob"}]');
-- Datalog: a table function, so the rows join against your own tables.
SELECT * FROM edn_q('default',
  '[:find ?e ?name :where [?e :person/name ?name]]', '{}');
SELECT * FROM edn_q('default',
  '[:find ?e . :in ?name :where [?e :person/name ?name]]', '{"inputs": ["Alice"]}');
-- The datoms are plain DuckDB rows.
SELECT count(*) FROM mentat.datoms;

About mentat

mentat is a Datomic-compatible database: an EDN/Datalog front-end over an entity-attribute-value store with history. This extension stores mentat's datoms in DuckDB: each mentat store is a schema of ordinary tables in the database the extension is loaded into, so the data persists with that database and plain SQL can read it. It exposes edn_t (transact), edn_q (Datalog query table function, with :in inputs and asOf/since), edn_pull (pull pattern -> JSON) and edn_eval (sandboxed mino script), so Datalog query results can be joined against native DuckDB tables. The same engine is also available as an embedded Rust library and CLI (on SQLite) and a PostgreSQL extension (pg_mentat). Source: https://codeberg.org/gregburd/mentat

Added Functions

function_name function_type description comment examples
edn_eval scalar NULL NULL  
edn_pull scalar NULL NULL  
edn_q table NULL NULL  
edn_t scalar NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

name description input_type scope aliases typed_value
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp