mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
feat: manage property graphs defined over tables
Replaces #4322, keeping only its property graph defined over tables. A property graph maps node labels and relationship types to existing tables of its namespace, in the shape of SQL/PGQ's `CREATE PROPERTY GRAPH`. It stores only that definition: a query reads the tables as nodes and edges through SQL `GRAPH_TABLE`, as they are when it runs. - **Rust:** `Connection::create_property_graph` takes a `PropertyGraphDefinition` of `NodeTable`s and `EdgeTable`s. `describe_property_graph`, `drop_property_graph` and `list_property_graphs` manage it. - **Python:** `lancedb.graph` has `NodeTable`, `EdgeTable` and `Endpoint`. Sync and async connections gain `create_property_graph`, `open_property_graph`, `drop_property_graph` and `list_property_graphs`, and a `PropertyGraph` handle describes its graph. - **Support:** remote connections only. Local connections raise `NotImplementedError` in Python and return `NotSupported` in Rust. ```python import lancedb from lancedb.graph import EdgeTable, Endpoint, NodeTable db = lancedb.connect("db://demo", api_key="...") db.create_property_graph( "social", nodes=[NodeTable("person", key="person_id", label="Person")], edges=[ EdgeTable( "knows", label="KNOWS", source=Endpoint("src_id", references=("person", "person_id")), destination=Endpoint("dst_id", references=("person", "person_id")), ) ], ) db.execute_query(""" SELECT * FROM GRAPH_TABLE (social MATCH (p:Person)-[:KNOWS]->(f:Person) WHERE p.age > 30 COLUMNS (p.name AS person, f.name AS friend)) """).read_all() ```
This commit is contained in:
@@ -493,6 +493,31 @@ automatic scheduling requests.
|
||||
|
||||
::: lancedb.view.ViewDescription
|
||||
|
||||
## Property Graphs
|
||||
|
||||
A property graph is defined over tables of its namespace: which tables hold
|
||||
nodes and which hold edges, each node table's key and label, and the node keys
|
||||
each edge table's source and destination columns reference -- the shape of
|
||||
SQL/PGQ's `CREATE PROPERTY GRAPH`. It stores no rows of its own; a query reads
|
||||
its tables as nodes and edges through SQL `GRAPH_TABLE`.
|
||||
|
||||
Create one with
|
||||
[create_property_graph][lancedb.db.DBConnection.create_property_graph], and
|
||||
manage it with
|
||||
[open_property_graph][lancedb.db.DBConnection.open_property_graph],
|
||||
[list_property_graphs][lancedb.db.DBConnection.list_property_graphs] and
|
||||
[drop_property_graph][lancedb.db.DBConnection.drop_property_graph].
|
||||
|
||||
::: lancedb.graph.NodeTable
|
||||
|
||||
::: lancedb.graph.EdgeTable
|
||||
|
||||
::: lancedb.graph.Endpoint
|
||||
|
||||
::: lancedb.graph.PropertyGraph
|
||||
|
||||
::: lancedb.graph.PropertyGraphDescription
|
||||
|
||||
## Expressions
|
||||
|
||||
Type-safe expression builder for filters and projections. Use these instead
|
||||
@@ -840,6 +865,14 @@ Table hold your actual data as a collection of records / rows.
|
||||
|
||||
::: lancedb.materialized_view.AsyncMaterializedView
|
||||
|
||||
## Property Graphs (Asynchronous)
|
||||
|
||||
`AsyncConnection` returns this handle from
|
||||
[create_property_graph][lancedb.db.AsyncConnection.create_property_graph] and
|
||||
[open_property_graph][lancedb.db.AsyncConnection.open_property_graph].
|
||||
|
||||
::: lancedb.graph.AsyncPropertyGraph
|
||||
|
||||
## Indices (Asynchronous)
|
||||
|
||||
Indices can be created on a table to speed up queries. This section
|
||||
|
||||
Reference in New Issue
Block a user