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 catalogCall, 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). - schema
- A graph as a schema:
<graph>.edgesand<graph>.nodes. - traversal
- The traversals in SQL:
hop,shortest_pathandrandom_walk.
Structs§
- Build
Info - What a build is for, as notices describe it.
- Edge
Spec - An edge table as written, with the key column each
REFERENCESnames. - Edge
Table - An edge table: each row is an edge from
sourcetodestination. - File
Identity - The identity of one source file, as its store reports it.
- File
Table - A table a graph opened from a file path or URL when it was created.
- Graph
Algorithm Exec - Builds or fetches a graph index from its child’s edge rows, and runs graph functions over it.
- Graph
Algorithm Node - Run graph functions over the edges its input produces.
- Graph
Def - 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. - Graph
Index - A built graph: its topology, and the map from dense node indexes back to the edges’ ids.
- Graph
Planner - Plans Ursa’s graph nodes.
- Graph
Registry - The graphs defined in one session, by name. Names are compared as given (the DDL normalizes identifiers the way DataFusion does for tables).
- Graph
Spec - A graph as
CREATE PROPERTY GRAPHwrote it, its identifiers normalized, beforecreate_graphresolves its vertex keys. - Graph
Traversal Exec - 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.
- Graph
Traversal Node - Run a traversal (
hop,shortest_path,random_walk) over the edges its first input produces. - Index
Cache - The session’s graph indexes (a session config extension).
- Keep
Edge Order - 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
fieldofcall, namedname. - Property
Graph - One graph, as
CREATE PROPERTY GRAPHdefined it: its vertex and edge tables (SQL/PGQ’s element tables), with their keys resolved (#295). - Ursa
Functions - The
ursa_functions()table function. - Ursa
Query Planner - A query planner whose physical planner knows Ursa’s graph nodes.
- Vertex
Spec - A vertex table as written: its
KEYmay be left out. - Vertex
Table - A vertex table: each row is a node, keyed by
key.
Enums§
- 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(akind: “table” or “view”) while a graph uses it. - check_
drop_ schema - Refuse to drop the schema
schemawhile it is a graph’s, or holds a table a graph uses. - check_
replace - Refuse to replace
table(akind) by one with the columnsschemawhile 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
candidatestonameby edit distance, if any is close enough to be a likely typo: for “did you mean” suggestions. - create_
graph - Define
specinctx, asCREATE [OR REPLACE] PROPERTY GRAPH [IF NOT EXISTS]does. Follows DataFusion’sCREATE TABLE: an existing graph is an error, unlessor_replace(replace it) orif_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
nameand its schema, asDROP PROPERTY GRAPH [IF EXISTS]does. - index_
builds - How many graph indexes
ctxhas built: for tests of the cache. - index_
loads - How many graph indexes
ctxhas loaded from its database’s stored indexes instead of building them: for tests of stored indexes. - 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.- unknown_
graph - The error for a graph that does not exist, with a suggestion.
Type Aliases§
- Weights
- Weight columns, one
f64per edge row each, in the order of a node’s weight expressions.