Skip to content
DuckDB community extension

duckgql

Adds ISO GQL graph querying and graph algorithms to DuckDB

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 · SQL
INSTALL duckgql FROM community;
LOAD duckgql FROM community;

Try it in a temporary SQL session with duckgql already loaded. Queries run in this tab; examples using files or services need their own setup.

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

SQL
COPY (
  SELECT * FROM (VALUES
    ('p1', 'Ada', 'Person'),
    ('p2', 'Grace', 'Person')
  ) nodes(":ID(People)", "name:string", ":LABEL")
) TO 'duckgql_nodes.csv' (FORMAT CSV, HEADER);

COPY (
  SELECT * FROM (VALUES
    ('p1', 'p2', 'KNOWS')
  ) edges(":START_ID(People)", ":END_ID(People)", ":TYPE")
) TO 'duckgql_edges.csv' (FORMAT CSV, HEADER);

CREATE GRAPH social ANY;

COPY GRAPH social FROM (
  VERTICES 'duckgql_nodes.csv',
  EDGES 'duckgql_edges.csv'
) FORMAT GRAPH;

SESSION SET GRAPH social;

MATCH (person:Person)-[:KNOWS]->(friend:Person)
RETURN person.name, friend.name;

Provided by rahul-iyer. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

DuckGQL is an experimental C++17 extension that adds a growing subset of ISO/IEC 39075:2024 GQL to DuckDB. It combines graph pattern queries and mutations with DuckDB's native relational storage and execution engine, plus an explicit CSR layer for graph algorithms.

Managed vertices and edges remain authoritative ordinary DuckDB tables rather than entity-attribute-value rows. For referenced graphs, the mapped DuckDB or DuckLake source tables remain authoritative and DuckGQL persists only the typed graph mapping. Nodes retain their complete label set and each edge has exactly one immutable type. DuckGQL lowers graph queries to native DuckDB relational plans, allowing DuckDB to execute scans, joins, aggregation, ordering, and recursive CTEs. The graph optimizer can choose table scans, native property indexes, node-label postings, and selective fixed-hop CSR expansion. CSR snapshots are immutable, database-instance scoped, version checked, and derived rather than authoritative.

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
rahul-iyer/duckdb-gql
License
MIT
Maintainers
rahul-iyer
Written in
C++
Build source
549eb4f70e74
Build definition
Community descriptor