rustfs_s3select_api/query/
logical_planner.rs1use async_trait::async_trait;
16use datafusion::arrow::datatypes::SchemaRef;
17use datafusion::logical_expr::LogicalPlan as DFPlan;
18use std::sync::Arc;
19
20use crate::QueryResult;
21
22use super::ast::ExtStatement;
23use super::session::SessionCtx;
24
25#[derive(Clone)]
26pub enum Plan {
27 Query(QueryPlan),
30}
31
32impl Plan {
33 pub fn schema(&self) -> SchemaRef {
34 match self {
35 Self::Query(p) => Arc::new(p.df_plan.schema().as_arrow().clone()),
36 }
37 }
38}
39
40#[derive(Debug, Clone)]
41pub struct QueryPlan {
42 pub df_plan: DFPlan,
43 pub is_tag_scan: bool,
44}
45
46impl QueryPlan {
47 pub fn is_explain(&self) -> bool {
48 matches!(self.df_plan, DFPlan::Explain(_) | DFPlan::Analyze(_))
49 }
50}
51
52#[async_trait]
53pub trait LogicalPlanner {
54 async fn create_logical_plan(&self, statement: ExtStatement, session: &SessionCtx) -> QueryResult<Plan>;
55}