Skip to content
Ursa Shell

Introduction

Ursa SQL is a SQL engine for graph analytics, used through a command-line tool called ursa. It works like DuckDB. You point it at Parquet, CSV, JSON or Arrow files, on your disk or in object storage, and query them with SQL. Graph algorithms are part of that SQL. Nothing needs converting or loading first.

CREATE VIEW ties AS SELECT * FROM 'karate_edges.csv';
CREATE PROPERTY GRAPH club
EDGE TABLES (ties SOURCE KEY (src) DESTINATION KEY (dst));
SELECT * FROM pagerank(club, direction => 'both')
ORDER BY pagerank DESC
LIMIT 3;
┌───────┬─────────────────────┐
│ id │ pagerank │
│ Int64 │ Float64 │
├───────┼─────────────────────┤
│ 33 │ 0.10091893648817557 │
│ 0 │ 0.09699751091990577 │
│ 32 │ 0.07169303486619161 │
└───────┴─────────────────────┘

Try it live in Ursa Shell, which runs the same engine in your browser: the link shows the three statements and runs them when you answer y. Or take the tour, five steps on the karate club from PageRank to a drawing of the graph. To install ursa, see Installation.

  • Files are tables. SELECT * FROM 'edges.parquet' reads the file: Parquet, CSV, JSON/NDJSON (.json, .jsonl, .ndjson) and Arrow. Globs, directories and compressed CSV and JSON work too. So do s3://, gs://, az:// and https:// URLs, and DuckDB’s read_parquet, read_csv and read_json.
  • A graph is an edge table. CREATE PROPERTY GRAPH, from the SQL standard (SQL/PGQ), names the edge table and its two endpoint columns. A node table with attributes is optional.
  • Algorithms are table functions. pagerank(club) returns one row per node. Join it to anything on id. Parameters are named: damping => 0.9.
  • A database file keeps your work. ursa club.ursa keeps your views, graphs and the graph indexes Ursa builds, so the next query does not rebuild them.

The engine is built on Apache DataFusion, so the rest of SQL works as DataFusion runs it: joins, aggregates, window functions, COPY … TO.

Ursa began as a Python library, ursa-graph on PyPI, with a Polars-shaped DataFrame API over the same Rust core. It is on hold: Ursa is developed as a SQL engine now, and the library may not be maintained. Its algorithms are the same kernels and give the same values. See its README.