Expand description
Lance Graph Query Engine
This crate provides graph query capabilities for Lance datasets using Cypher syntax. It interprets Lance datasets as property graphs and translates Cypher queries into DataFusion SQL queries for execution.
§Features
- Cypher query parsing and AST representation
- Graph pattern matching on columnar data
- Property graph interpretation of Lance datasets
- Translation to optimized SQL via DataFusion
- Support for nodes, relationships, and properties
- A CSR (compressed sparse row) adjacency index for multi-hop traversal
§Example
CypherEngine registers datasets once, optionally builds the CSR, and serves
many queries. See engine for the full API and examples/embedded_query.rs
for a runnable program.
use std::collections::HashMap;
use lance_csr::{CypherEngine, EngineSource, GraphConfig, Result};
let config = GraphConfig::builder()
.node_table("Person", "person_id")
.rel_table("KNOWS", "Person", "Person", "src_person_id", "dst_person_id")
.build()?;
let sources = HashMap::from([
("Person".to_string(), EngineSource::open_lance("person.lance", None, HashMap::new()).await?),
("KNOWS".to_string(), EngineSource::open_lance("knows.lance", None, HashMap::new()).await?),
]);
let engine = CypherEngine::new(config, sources, true).await?;
let batch = engine
.execute("MATCH (p:Person) WHERE p.age > 30 RETURN p.name", HashMap::new())
.await?;Re-exports§
pub use config::GraphConfig;pub use config::NodeMapping;pub use config::RelationshipMapping;pub use csr_index::CsrIndex;pub use csr_index::CsrIndexBuilder;pub use engine::CypherEngine;pub use engine::EngineSource;pub use error::GraphError;pub use error::Result;pub use lance_vector_search::VectorSearch;pub use query::CypherQuery;pub use query::ExecutionStrategy;pub use query::SqlDialect;pub use sql_query::SqlQuery;
Modules§
- ast
- Abstract Syntax Tree for Cypher queries
- case_
insensitive - Case-insensitive string utilities
- config
- Graph configuration for mapping Lance datasets to property graphs
- csr_
expand - Experimental CSR-backed single-hop expansion.
- csr_
index - CSR (Compressed Sparse Row) adjacency index for native graph traversal
- datafusion_
planner - DataFusion-based physical planner for graph queries
- engine
- A Cypher engine that registers its datasets once and serves many queries.
- error
- Error types for the Lance graph query engine
- key_
statistics - Distinct-count statistics for join-key columns, so DataFusion sizes joins correctly.
- lance_
vector_ search - Lance Vector Search API for lance-csr
- logical_
plan - Logical planning for graph queries
- parameter_
substitution - parser
- Cypher query parser
- query
- High-level Cypher query interface for Lance datasets
- semantic
- Semantic analysis for graph queries
- shortest_
path shortestPath/allShortestPathsas a breadth-first search over the adjacency.- spark_
dialect - Spark SQL dialect for the DataFusion unparser.
- sql_
query - Direct SQL query interface for Lance datasets
Structs§
- DirNamespace
- A namespace that resolves table names relative to a base directory or URI.
- InMemory
Catalog - A simple in-memory catalog useful for tests and bootstrap wiring.
- Simple
Table Source - A trivial logical table source with a fixed schema.
Constants§
- MAX_
VARIABLE_ LENGTH_ HOPS - Maximum allowed hops for variable-length relationship expansion (e.g., *1..N)
Traits§
- Graph
Source Catalog - A minimal catalog to resolve node labels and relationship types to logical table sources.