use crate::config::GraphConfig;
use crate::datafusion_planner::GraphPhysicalPlanner;
use crate::error::Result;
use crate::logical_plan::LogicalOperator;
use datafusion::common::DFSchema;
use datafusion::logical_expr::{EmptyRelation, LogicalPlan};
use std::sync::Arc;
pub struct LanceNativePlanner {
#[allow(dead_code)]
config: GraphConfig,
}
impl LanceNativePlanner {
pub fn new(config: GraphConfig) -> Self {
Self { config }
}
}
impl GraphPhysicalPlanner for LanceNativePlanner {
fn plan(&self, _logical_plan: &LogicalOperator) -> Result<LogicalPlan> {
let schema = Arc::new(DFSchema::empty());
Ok(LogicalPlan::EmptyRelation(EmptyRelation {
produce_one_row: false,
schema,
}))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_lance_native_planner_placeholder() {
let cfg = GraphConfig::builder()
.with_node_label("Person", "id")
.build()
.unwrap();
let planner = LanceNativePlanner::new(cfg);
let lp = LogicalOperator::Distinct {
input: Box::new(LogicalOperator::Limit {
input: Box::new(LogicalOperator::Project {
input: Box::new(LogicalOperator::ScanByLabel {
variable: "n".to_string(),
label: "Person".to_string(),
properties: Default::default(),
}),
projections: vec![],
}),
count: 1,
}),
};
let df_plan = planner.plan(&lp).unwrap();
match df_plan {
LogicalPlan::EmptyRelation(_) => {}
_ => panic!("expected empty relation placeholder"),
}
}
}