Skip to content
Ursa Shell

Statements

Ursa runs the SQL that DataFusion runs: SELECT, joins, aggregates, window functions, CREATE VIEW, CREATE EXTERNAL TABLE, COPY … TO, EXPLAIN, SET and SHOW. This page covers what Ursa adds: reading files, and statements for graphs, databases and settings.

Statement What it does Page
SELECT … FROM 'file.parquet', read_parquet, read_csv, read_json Read a file as a table Files
COPY … TO Write a query’s rows to a file Files
CREATE PROPERTY GRAPH Define a graph over vertex and edge tables Property graphs
DROP PROPERTY GRAPH Drop a graph Property graphs
SHOW GRAPHS List the graphs Property graphs
DESCRIBE GRAPH List a graph’s columns Property graphs
GRAPH_TABLE Match patterns of nodes and edges Pattern matching
ATTACH Open a database file ATTACH, below
SET, SHOW, RESET Change and read a setting Settings

The examples below share one session, over the karate club graph:

CREATE VIEW members AS SELECT * FROM 'karate_nodes.csv';
CREATE VIEW ties AS SELECT * FROM 'karate_edges.csv';
CREATE PROPERTY GRAPH karate
VERTEX TABLES (members KEY (id))
EDGE TABLES (
ties SOURCE KEY (src) REFERENCES members (id)
DESTINATION KEY (dst) REFERENCES members (id)
);

ATTACH 'file.ursa' opens a database file in an in-memory session, as if ursa file.ursa had opened it. The shell’s .open runs it.

ATTACH 'club.ursa';

The session must not have a database already, and must not have defined anything yet. ATTACH DATABASE 'file.ursa' is the same. An alias (AS other) is parsed but not supported yet. The database file explains what the file keeps.

The algorithms, statistics and traversals are table functions. They go in FROM, take the graph as the first argument and named parameters with =>:

SELECT * FROM degree(karate, direction => 'both') ORDER BY degree DESC LIMIT 1;
┌───────┬────────┐
│ id │ degree │
│ Int64 │ UInt32 │
├───────┼────────┤
│ 33 │ 17 │
└───────┴────────┘

SELECT * FROM ursa_functions() lists them all, and the function reference describes each one.