lance_graph/
lance_native_planner.rs1use crate::config::GraphConfig;
14use crate::datafusion_planner::GraphPhysicalPlanner;
15use crate::error::Result;
16use crate::logical_plan::LogicalOperator;
17use datafusion::common::DFSchema;
18use datafusion::logical_expr::{EmptyRelation, LogicalPlan};
19use std::sync::Arc;
20
21pub struct LanceNativePlanner {
23 #[allow(dead_code)]
24 config: GraphConfig,
25}
26
27impl LanceNativePlanner {
28 pub fn new(config: GraphConfig) -> Self {
29 Self { config }
30 }
31}
32
33impl GraphPhysicalPlanner for LanceNativePlanner {
34 fn plan(&self, _logical_plan: &LogicalOperator) -> Result<LogicalPlan> {
35 let schema = Arc::new(DFSchema::empty());
38 Ok(LogicalPlan::EmptyRelation(EmptyRelation {
39 produce_one_row: false,
40 schema,
41 }))
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_lance_native_planner_placeholder() {
51 let cfg = GraphConfig::builder()
52 .with_node_label("Person", "id")
53 .build()
54 .unwrap();
55 let planner = LanceNativePlanner::new(cfg);
56 let lp = LogicalOperator::Distinct {
58 input: Box::new(LogicalOperator::Limit {
59 input: Box::new(LogicalOperator::Project {
60 input: Box::new(LogicalOperator::ScanByLabel {
61 variable: "n".to_string(),
62 label: "Person".to_string(),
63 properties: Default::default(),
64 }),
65 projections: vec![],
66 }),
67 count: 1,
68 }),
69 };
70 let df_plan = planner.plan(&lp).unwrap();
71 match df_plan {
73 LogicalPlan::EmptyRelation(_) => {}
74 _ => panic!("expected empty relation placeholder"),
75 }
76 }
77}