Skip to main content

lance_graph/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright The Lance Authors
3
4//! Lance Graph Query Engine
5//!
6//! This crate provides graph query capabilities for Lance datasets using Cypher syntax.
7//! It interprets Lance datasets as property graphs and translates Cypher queries into
8//! DataFusion SQL queries for execution.
9//!
10//! # Features
11//!
12//! - Cypher query parsing and AST representation
13//! - Graph pattern matching on columnar data
14//! - Property graph interpretation of Lance datasets
15//! - Translation to optimized SQL via DataFusion
16//! - Support for nodes, relationships, and properties
17//!
18//! # Example
19//!
20//! ```no_run
21//! use lance_graph::{CypherQuery, GraphConfig, Result};
22//!
23//! # fn example() -> Result<()> {
24//! let config = GraphConfig::builder()
25//!     .with_node_label("Person", "person_id")
26//!     .with_relationship("KNOWS", "src_person_id", "dst_person_id")
27//!     .build()?;
28//!
29//! let query = CypherQuery::new("MATCH (p:Person) WHERE p.age > 30 RETURN p.name")?
30//!     .with_config(config);
31//!
32//! // Execute against a dataset (would need actual dataset integration)
33//! // let results = query.execute(&dataset).await?;
34//! # Ok(())
35//! # }
36//! ```
37
38pub mod ast;
39pub mod case_insensitive;
40pub mod config;
41pub mod datafusion_planner;
42pub mod error;
43pub mod lance_native_planner;
44pub mod lance_vector_search;
45pub mod logical_plan;
46pub mod parameter_substitution;
47pub mod parser;
48pub mod query;
49pub mod semantic;
50pub mod sql_catalog;
51pub mod sql_query;
52pub mod table_readers;
53
54/// Maximum allowed hops for variable-length relationship expansion (e.g., *1..N)
55pub const MAX_VARIABLE_LENGTH_HOPS: u32 = 20;
56
57pub use config::{GraphConfig, NodeMapping, RelationshipMapping};
58pub use error::{GraphError, Result};
59pub use lance_graph_catalog::{
60    DirNamespace, GraphSourceCatalog, InMemoryCatalog, SimpleTableSource,
61};
62// Catalog provider re-exports
63pub use lance_graph_catalog::{
64    CatalogError, CatalogInfo, CatalogProvider, CatalogResult, ColumnInfo, Connector,
65    DataSourceFormat, SchemaInfo, TableInfo, TableReader, TableType,
66};
67#[cfg(feature = "unity-catalog")]
68pub use lance_graph_catalog::{UnityCatalogConfig, UnityCatalogProvider};
69pub use lance_vector_search::VectorSearch;
70pub use query::{CypherQuery, ExecutionStrategy};
71pub use sql_query::SqlQuery;
72#[cfg(feature = "delta")]
73pub use table_readers::DeltaTableReader;
74pub use table_readers::{default_table_readers, ParquetTableReader};