Skip to content

Commit 6bb087a

Browse files
authored
doc: update the rust readme (#56)
1 parent 9e9b8f1 commit 6bb087a

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

rust/lance-graph/README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ A graph query engine for Lance datasets with Cypher syntax support. This crate e
77
- Cypher query parsing and AST construction
88
- Graph configuration for mapping Lance tables to nodes and relationships
99
- Semantic validation with typed `GraphError` diagnostics
10-
- Translation to DataFusion SQL with a direct-execution fast path for simple patterns
10+
- Pluggable execution strategies (DataFusion planner by default, simple executor, Lance Native placeholder)
1111
- Async query execution that returns Arrow `RecordBatch` results
1212
- JSON-serializable parameter binding for reusable query templates
13+
- Logical plan debugging via `CypherQuery::explain`
1314

1415
## Quick Start
1516

@@ -19,7 +20,7 @@ use std::sync::Arc;
1920

2021
use arrow_array::{ArrayRef, Int32Array, RecordBatch, StringArray};
2122
use arrow_schema::{DataType, Field, Schema};
22-
use lance_graph::{CypherQuery, GraphConfig};
23+
use lance_graph::{CypherQuery, ExecutionStrategy, GraphConfig};
2324

2425
let config = GraphConfig::builder()
2526
.with_node_label("Person", "person_id")
@@ -48,7 +49,11 @@ let query = CypherQuery::new("MATCH (p:Person) WHERE p.age > $min RETURN p.name"
4849
.with_parameter("min", 30);
4950

5051
let runtime = tokio::runtime::Runtime::new()?;
51-
let result = runtime.block_on(query.execute(tables))?;
52+
// Use default DataFusion-based execution
53+
let result = runtime.block_on(query.execute(tables.clone(), None))?;
54+
55+
// Opt in to the simple executor if you only need projection/filter support.
56+
let simple = runtime.block_on(query.execute(tables, Some(ExecutionStrategy::Simple)))?;
5257
```
5358

5459
The query expects a `HashMap<String, RecordBatch>` keyed by the labels and relationship types referenced in the Cypher text. Each record batch should expose the columns configured through `GraphConfig` (ID fields, property fields, etc.). Relationship mappings also expect a batch keyed by the relationship type (for example `KNOWS`) that contains the configured source/target ID columns and any optional property columns.
@@ -87,9 +92,10 @@ let config = GraphConfig::builder()
8792
- `CypherQuery::new` parses Cypher text into the internal AST.
8893
- `with_config` attaches the graph configuration used for validation and execution.
8994
- `with_parameter` / `with_parameters` bind JSON-serializable values that can be referenced as `$param` in the Cypher text.
90-
- `execute` is asynchronous and returns an Arrow `RecordBatch`.
95+
- `execute` is asynchronous and returns an Arrow `RecordBatch`. Pass `None` for the default DataFusion planner or `Some(ExecutionStrategy::Simple)` for the single-table executor. `ExecutionStrategy::LanceNative` is reserved for future native execution support and currently errors.
96+
- `explain` is asynchronous and returns a formatted string containing the graph logical plan alongside the DataFusion logical and physical plans.
9197

92-
Queries with a single `MATCH` clause containing a path pattern are planned as joins using the provided mappings. Other queries fall back to a single-table projection/filter pipeline on the first registered dataset.
98+
Queries with a single `MATCH` clause containing a path pattern are planned as joins using the provided mappings. Other queries can opt into the single-table projection/filter pipeline via `ExecutionStrategy::Simple` when DataFusion's planner is unnecessary.
9399

94100
A builder (`CypherQueryBuilder`) is also available for constructing queries programmatically without parsing text.
95101

@@ -101,15 +107,16 @@ A builder (`CypherQueryBuilder`) is also available for constructing queries prog
101107
- RETURN lists of property accesses, optional `DISTINCT`, `ORDER BY`, `SKIP` (offset), and `LIMIT`.
102108
- Positional and named parameters (e.g. `$min_age`).
103109

104-
Features such as aggregations, optional matches, and subqueries are parsed but not executed yet.
110+
Basic aggregations like `COUNT` are supported. Optional matches and subqueries are parsed but not executed yet.
105111

106112
## Crate Layout
107113

108114
- `ast` – Cypher AST definitions.
109115
- `parser` – Nom-based Cypher parser.
110116
- `semantic` – Lightweight semantic checks on the AST.
111-
- `logical_plan` – Builders for DataFusion logical plans.
112-
- `datafusion_planner` and `query_processor` – Execution planning utilities.
117+
- `logical_plan` – Builders for graph logical plans.
118+
- `datafusion_planner` – DataFusion-based execution planning.
119+
- `simple_executor` – Simple single-table executor.
113120
- `config` – Graph configuration types and builders.
114121
- `query` – High level `CypherQuery` API and runtime.
115122
- `error``GraphError` and result helpers.

0 commit comments

Comments
 (0)