-
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
2a27ef2
commit e32053c
Showing
6 changed files
with
60 additions
and
32 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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
#[name=two_way_simple, run=plan]> | ||
SELECT * FROM books b | ||
INNER JOIN categories c ON b.category_id = c.id | ||
WHERE c.name = 'Science'; | ||
--- | ||
- filter (c.name IsEqual Str("Science")): | ||
- join [Inner, (b.category_id IsEqual c.id)]: | ||
- scan [books as b] | ||
- scan [categories as c] | ||
|
||
|
||
#[name=three_way_simple, run=plan]> | ||
|
||
SELECT * FROM books b | ||
INNER JOIN categories c ON b.category_id = c.id | ||
INNER JOIN publishers AS p ON b.publisher_id = p.id | ||
WHERE p.name = 'Springer'; | ||
|
||
--- | ||
|
||
- filter (p.name IsEqual Str("Springer")): | ||
- join [Inner, (b.publisher_id IsEqual p.id)]: | ||
- join [Inner, (b.category_id IsEqual c.id)]: | ||
- scan [books as b] | ||
- scan [categories as c] | ||
- scan [publishers as p] |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
#![recursion_limit = "192"] | ||
use util::run_test; | ||
use test_each_file::test_each_file; | ||
|
||
mod runtime; | ||
mod planner; | ||
mod util; | ||
|
||
test_each_file! { in "lykiadb-server/tests/planner" => run_test } |
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::stmt::Stmt, parser::program::Program}; | ||
use lykiadb_server::plan::planner::Planner; | ||
|
||
fn expect_plan(query: &str, expected_plan: &str) { | ||
let mut planner = Planner::new(); | ||
let program = query.parse::<Program>().unwrap(); | ||
match *program.get_root() { | ||
Stmt::Program { body, .. } if matches!(body.get(0), Some(Stmt::Expression { .. })) => { | ||
if let Some(Stmt::Expression { expr, .. }) = body.get(0) { | ||
let generated_plan = planner.build(&expr).unwrap(); | ||
assert_eq!(expected_plan, generated_plan.to_string().trim()); | ||
} | ||
} | ||
_ => panic!("Expected expression statement."), | ||
} | ||
} | ||
|
||
pub fn run_test(input: &str) { | ||
let parts: Vec<&str> = input.split("#[").collect(); | ||
|
||
for part in parts[1..].iter() { | ||
let directives_and_input = part.trim(); | ||
let directives_end = directives_and_input.find('>').unwrap_or(directives_and_input.len()); | ||
let rest = directives_and_input[directives_end+1..].trim().to_string(); | ||
let io_parts: Vec<&str> = rest.split("---").collect(); | ||
expect_plan(&io_parts[0].trim(),&io_parts[1].trim()); | ||
} | ||
} |