Skip to main content

Module graph

Module graph 

Source
Expand description

Graphs in a session: their definitions and where they are kept.

A graph is defined by CREATE PROPERTY GRAPH (SQL/PGQ) over tables or views already in the session: one edge table with a source and a destination column, and optionally one vertex table keyed by an id column. Without a vertex table, the nodes are the endpoints of the edges.

This module is the contract between the graph DDL (which creates and drops GraphDefs) and everything that reads graphs: the <graph>.nodes and <graph>.edges tables and the algorithm table functions. Definitions are held per session in a GraphRegistry, stored as a session config extension so any code holding the session state can reach it.

A definition names tables; it does not copy or pin their rows. Every query plans the edge table afresh, so a graph over a view of a file sees the file’s current contents.

An edge or vertex table may also be a file path or URL, as in FROM (EDGE TABLES ('edges.csv' SOURCE KEY (src) DESTINATION KEY (dst))). It is opened once, when the graph is created, as a listing table that the registry keeps for that graph (GraphRegistry::file_table); it is not registered under any name, so it never shows in a listing. Like a view over the file, it fixes the file’s columns at that point and reads the file’s current rows on every query.

Tables a graph uses cannot be dropped, or replaced by ones the graph’s definition no longer fits, while the graph exists (check_drop, check_replace). If one disappears anyway (through the DataFusion API), <graph>.nodes and <graph>.edges fail when queried, and session listings keep working.

Algorithms over a graph are table functions, FROM pagerank(g), planned as a GraphAlgorithmNode whose child is the edge table (functions, relation, node, exec), with the built index cached per session (IndexCache).

Traversals (hop, shortest_path, random_walk) are table functions too, planned as a GraphTraversalNode over the same edge plan, with one more child per node-id argument (a list, or a subquery that runs when the node runs); see traversal.

Re-exports§

pub use schema::edges_plan;
pub use schema::edges_plan_from;
pub use schema::nodes_plan;
pub use schema::nodes_plan_from;
pub use schema::GraphSchema;

Modules§

functions
The graph functions in SQL: which of ursa_core::catalog’s functions a query can call, how a call’s SQL arguments become a catalog Call, and the wording of every message about them.
path_search
Searching paths on the graph index: SQL/PGQ’s quantified edges (-[e]->{1,3}, -[e]->*), path variables, selectors (ANY SHORTEST, ALL SHORTEST, SHORTEST k) and path modes (TRAIL, SIMPLE, ACYCLIC) (#297).
pattern
SQL/PGQ pattern matching: GRAPH_TABLE (g MATCH … COLUMNS (…)) (#296).
provenance
What a result’s columns are: the ursa.* Arrow field metadata the graph functions and GRAPH_TABLE put on their output (#431).
schema
A graph as a schema: <graph>.edges and <graph>.nodes.
traversal
The traversals in SQL: hop, shortest_path, random_walk and induced_edges.
view
A result as a graph (design §3 and §6, #425): what .graph draws, as a GraphResult any front end can show: the browser shell, and the CLI and the notebook after it.

Structs§

BuildInfo
What a build is for, as notices describe it.
EdgeSpec
An edge table as written, with the key column each REFERENCES names.
EdgeTable
An edge table: each row is an edge from source to destination.
FileIdentity
The identity of one source file, as its store reports it.
FileTable
A table a graph opened from a file path or URL when it was created.
GraphAlgorithmExec
Builds or fetches a graph index from its child’s edge rows, and runs graph functions over it.
GraphAlgorithmNode
Run graph functions over the edges its input produces.
GraphDef
A graph as an algorithm sees it: one edge table, and the vertex table its endpoints refer to, if any. A whole graph before #295; now one pair of a PropertyGraph.
GraphIndex
A built graph: its topology, and the map from dense node indexes back to the edges’ ids.
GraphPlanner
Plans Ursa’s graph nodes.
GraphRegistry
The graphs defined in one session, by name. Names are compared as given (the DDL normalizes identifiers the way DataFusion does for tables).
GraphSpec
A graph as CREATE PROPERTY GRAPH wrote it, its identifiers normalized, before create_graph resolves its vertex keys.
GraphTraversalExec
Builds or fetches a graph index from its first child’s edge rows, reads the node ids its other children produce, and runs a traversal.
GraphTraversalNode
Run a traversal (hop, shortest_path, random_walk, induced_edges) over the edges its first input produces.
IndexCache
The session’s graph indexes (a session config extension).
KeepEdgeOrder
Keeps a graph node’s edge rows in the order the plan produces them, and gives them a fixed order where the plan has none.
Label
A label of an element table, and the properties it exposes.
Output
One output column of a graph node: output field of call, named name.
PropertyGraph
One graph, as CREATE PROPERTY GRAPH defined it: its vertex and edge tables (SQL/PGQ’s element tables), with their keys resolved (#295).
UnavailableGraph
A graph of the session’s database that could not be defined when it was opened (see GraphRegistry::mark_unavailable).
UrsaFunctions
The ursa_functions() table function.
UrsaQueryPlanner
A query planner whose physical planner knows Ursa’s graph nodes.
VertexSpec
A vertex table as written: its KEY may be left out.
VertexTable
A vertex table: each row is a node, keyed by key.

Enums§

BuildSize
How much a build reads, as its first notice says it.
IndexHeld
Where a session keeps an index (IndexCache::holds).
Properties
The properties a label exposes.

Functions§

check_ddl
Refuse a DDL statement, planned as plan, that would break a graph:
check_drop
Refuse to drop table (a kind: “table” or “view”) while a graph uses it.
check_drop_schema
Refuse to drop the schema schema while it is a graph’s, or holds a table a graph uses.
check_replace
Refuse to replace table (a kind) by one with the columns schema while a graph uses it and its definition does not fit those columns. None: the new columns are not known yet, so the replacement is refused whenever a graph uses the table.
closest_name
The closest of candidates to name by edit distance, if any is close enough to be a likely typo: for “did you mean” suggestions.
create_graph
Define spec in ctx, as CREATE [OR REPLACE] PROPERTY GRAPH [IF NOT EXISTS] does. Follows DataFusion’s CREATE TABLE: an existing graph is an error, unless or_replace (replace it) or if_not_exists (keep it, do nothing).
describe_graph
DESCRIBE GRAPH name: one row per column of <name>.nodes, then of <name>.edges, saying what each is and where it comes from.
drop_graph
Drop the graph called name and its schema, as DROP PROPERTY GRAPH [IF EXISTS] does.
index_builds
How many graph indexes ctx has built: for tests of the cache.
index_loads
How many graph indexes ctx has loaded from its database’s stored indexes instead of building them: for tests of stored indexes.
mark_unavailable
Mark the database’s graph called name unavailable: it could not be defined when the database was opened, and message says why (#381). Using it fails with message until it is dropped or replaced: its functions, GRAPH_TABLE, DESCRIBE GRAPH, and its edges and nodes tables, for which it gets its schema (#401). definition, its stored definition if it could be read, is what SHOW GRAPHS lists for it.
registry
The session’s graph registry.
registry_of
The graph registry of ctx.
show_graphs
SHOW GRAPHS: one row per edge table of each graph (one row for a graph with no edge tables), sorted by graph name, with its definition and whether it can be used.
unknown_graph
The error for a graph that does not exist, with a suggestion.
vertex_key_counts
How many times ctx has counted a vertex table’s keys to read it as <graph>.nodes or a GRAPH_TABLE node: for tests of what is kept.

Type Aliases§

Weights
Weight columns, one f64 per edge row each, in the order of a node’s weight expressions.