-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45b338d
commit ad70dc1
Showing
7 changed files
with
92 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use lykiadb_lang::ast::sql::SqlExpr; | ||
use serde::{Deserialize, Serialize}; | ||
pub mod planner; | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
pub enum Aggregate { | ||
Average(SqlExpr), | ||
Count(SqlExpr), | ||
Max(SqlExpr), | ||
Min(SqlExpr), | ||
Sum(SqlExpr), | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
pub enum Direction { | ||
Ascending, | ||
Descending, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
pub enum Plan { | ||
Select(Node) | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
pub enum Node { | ||
Aggregate { source: Box<Node>, group_by: Vec<SqlExpr>, aggregates: Vec<Aggregate> }, | ||
|
||
Filter { source: Box<Node>, predicate: SqlExpr }, | ||
|
||
Projection { source: Box<Node>, expressions: Vec<SqlExpr>, aliases: Vec<String> }, | ||
|
||
Scan { collection: String, filter: Option<SqlExpr>, alias: Option<String> }, | ||
|
||
Limit { source: Box<Node>, limit: usize }, | ||
|
||
Offset { source: Box<Node>, offset: usize }, | ||
|
||
Order { source: Box<Node>, key: Vec<(SqlExpr, Direction)> }, | ||
|
||
Values { rows: Vec<Vec<SqlExpr>> }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use lykiadb_lang::ast::{expr::Expr, sql::SqlSelect, visitor::ExprEvaluator}; | ||
|
||
use crate::{engine::interpreter::HaltReason, value::types::RV}; | ||
|
||
use super::{Node, Plan}; | ||
pub struct Planner; | ||
|
||
impl Planner { | ||
pub fn new() -> Planner { | ||
Planner {} | ||
} | ||
|
||
pub fn build(&mut self, expr: &Expr) -> Result<Plan, HaltReason> { | ||
match expr { | ||
Expr::Select { | ||
query, | ||
span: _, | ||
id: _ } => { | ||
self.build_select(query) | ||
}, | ||
_ => panic!("Not implemented yet.") | ||
} | ||
} | ||
|
||
fn build_select(&mut self, query: &SqlSelect) -> Result<Plan, HaltReason> { | ||
Ok(Plan::Select(Node::Values { rows: vec![vec![]] })) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters