Skip to content

Commit

Permalink
add binder and planner
Browse files Browse the repository at this point in the history
Signed-off-by: tangruilin <tang.ruilin@foxmail.com>
  • Loading branch information
Tangruilin committed Feb 1, 2024
1 parent 8e63752 commit becd3d4
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rust-analyzer.linkedProjects": [
"./Cargo.toml"
],
"cSpell.words": [
"Subquery"
]
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod error;
pub mod parser;
pub mod planner;
pub mod types;
4 changes: 2 additions & 2 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mod column;

mod data_type;
mod expression;
pub mod expression;
mod keyword;
pub mod lexer;
mod operation;
mod operator;
mod stmt;
pub(crate) mod stmt;
pub mod token;

use crate::parser::operator::{is_infix_oper, is_prefix_oper};
Expand Down
16 changes: 16 additions & 0 deletions src/planner/binder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::sync::Arc;

use crate::parser::stmt::Statement;

use super::logical_operation::LogicalPlan;

pub struct BoundStatement {
_names: Vec<String>,
plan: Arc<LogicalPlan>,
}

pub struct Binder {}

impl Binder {
pub fn create_plan(stmt: Statement) {}
}
49 changes: 49 additions & 0 deletions src/planner/logical_operation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use core::fmt::Debug;

use std::sync::Arc;

use crate::parser::expression::Expression;

#[derive(PartialEq, Debug, Clone)]
pub enum LogicalPlan {
Projection(Projection),
Filter(Filter),
Aggregate(Aggregate),
Sort,
Join,
Statement,
TableScan,
Subquery,
Limit,
Values,
Explain,
Dml,
Ddl,
}

/// Evaluates an arbitrary list of expressions (essentially a
/// SELECT with an expression list) on its input.
#[derive(PartialEq, Debug, Clone)]
// mark non_exhaustive to encourage use of try_new/new()
#[non_exhaustive]
pub struct Projection {
/// The list of expressions
pub expr: Vec<Expression>,
/// The incoming logical plan
pub input: Arc<LogicalPlan>,
/// The schema description of the output
pub schema: Option<String>,
}

#[derive(PartialEq, Debug, Clone)]
#[non_exhaustive]
pub struct Filter {
/// The predicate expression, which must have Boolean type.
pub predicate: Expression,
/// The incoming logical plan
pub input: Box<LogicalPlan>,
}

#[derive(PartialEq, Debug, Clone)]
#[non_exhaustive]
pub(crate) struct Aggregate {}
3 changes: 3 additions & 0 deletions src/planner/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod binder;
pub mod logical_operation;
pub mod planner;
13 changes: 13 additions & 0 deletions src/planner/planner.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use crate::parser::stmt::Statement;

use super::logical_operation::LogicalPlan;

pub struct Planner {
logic_plan: Option<LogicalPlan>,
}

impl Planner {
pub fn create_plan(&mut self, _stmt: Statement) {
self.logic_plan = None;
}
}
1 change: 1 addition & 0 deletions src/types/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit becd3d4

Please sign in to comment.