Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crates/lance-graph-python/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ use crate::RT;
pub enum ExecutionStrategy {
/// Use DataFusion query planner (default, full feature support)
DataFusion,
/// Use simple single-table executor (legacy, limited features)
Simple,
/// Use Lance native executor (not yet implemented)
LanceNative,
}
Expand All @@ -56,7 +54,6 @@ impl From<ExecutionStrategy> for RustExecutionStrategy {
fn from(strategy: ExecutionStrategy) -> Self {
match strategy {
ExecutionStrategy::DataFusion => RustExecutionStrategy::DataFusion,
ExecutionStrategy::Simple => RustExecutionStrategy::Simple,
ExecutionStrategy::LanceNative => RustExecutionStrategy::LanceNative,
}
}
Expand Down Expand Up @@ -548,7 +545,7 @@ impl CypherQuery {
///
/// >>> # Explicit strategy
/// >>> from lance.graph import ExecutionStrategy
/// >>> result = query.execute(datasets, strategy=ExecutionStrategy.Simple)
/// >>> result = query.execute(datasets, strategy=ExecutionStrategy.DataFusion)
#[pyo3(signature = (datasets, strategy=None))]
fn execute(
&self,
Expand Down
12 changes: 4 additions & 8 deletions crates/lance-graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A graph query engine for Lance datasets with Cypher syntax support. This crate e
- Cypher query parsing and AST construction
- Graph configuration for mapping Lance tables to nodes and relationships
- Semantic validation with typed `GraphError` diagnostics
- Pluggable execution strategies (DataFusion planner by default, simple executor, Lance Native placeholder)
- Pluggable execution strategies (DataFusion planner by default, Lance Native placeholder)
- Async query execution that returns Arrow `RecordBatch` results
- JSON-serializable parameter binding for reusable query templates
- Logical plan debugging via `CypherQuery::explain`
Expand Down Expand Up @@ -50,10 +50,7 @@ let query = CypherQuery::new("MATCH (p:Person) WHERE p.age > $min RETURN p.name"

let runtime = tokio::runtime::Runtime::new()?;
// Use default DataFusion-based execution
let result = runtime.block_on(query.execute(tables.clone(), None))?;

// Opt in to the simple executor if you only need projection/filter support.
let simple = runtime.block_on(query.execute(tables, Some(ExecutionStrategy::Simple)))?;
let result = runtime.block_on(query.execute(tables, None))?;
```

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.
Expand Down Expand Up @@ -92,10 +89,10 @@ let config = GraphConfig::builder()
- `CypherQuery::new` parses Cypher text into the internal AST.
- `with_config` attaches the graph configuration used for validation and execution.
- `with_parameter` / `with_parameters` bind JSON-serializable values that can be referenced as `$param` in the Cypher text.
- `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.
- `execute` is asynchronous and returns an Arrow `RecordBatch`. Pass `None` to use the default DataFusion planner. `ExecutionStrategy::LanceNative` is reserved for future native execution support and currently errors.
- `explain` is asynchronous and returns a formatted string containing the graph logical plan alongside the DataFusion logical and physical plans.

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.
All queries use the DataFusion planner for optimization and execution.

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

Expand All @@ -116,7 +113,6 @@ Basic aggregations like `COUNT` are supported. Optional matches and subqueries a
- `semantic` – Lightweight semantic checks on the AST.
- `logical_plan` – Builders for graph logical plans.
- `datafusion_planner` – DataFusion-based execution planning.
- `simple_executor` – Simple single-table executor.
- `config` – Graph configuration types and builders.
- `query` – High level `CypherQuery` API and runtime.
- `error` – `GraphError` and result helpers.
Expand Down
8 changes: 2 additions & 6 deletions crates/lance-graph/benches/graph_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use arrow_schema::{DataType, Field, Schema as ArrowSchema};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use futures::TryStreamExt;
use lance::dataset::{Dataset, WriteMode, WriteParams};
use lance_graph::{CypherQuery, ExecutionStrategy, GraphConfig};
use lance_graph::{CypherQuery, GraphConfig};
use tempfile::TempDir;

fn create_people_batch() -> RecordBatch {
Expand Down Expand Up @@ -71,11 +71,7 @@ fn execute_cypher_query(
q: &CypherQuery,
datasets: HashMap<String, RecordBatch>,
) -> RecordBatch {
rt.block_on(async move {
q.execute(datasets, Some(ExecutionStrategy::Simple))
.await
.unwrap()
})
rt.block_on(async move { q.execute(datasets, None).await.unwrap() })
}

fn make_people_batch(n: usize) -> RecordBatch {
Expand Down
1 change: 0 additions & 1 deletion crates/lance-graph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub mod parameter_substitution;
pub mod parser;
pub mod query;
pub mod semantic;
pub mod simple_executor;
pub mod sql_catalog;
pub mod sql_query;
pub mod table_readers;
Expand Down
Loading
Loading