-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impl display for scalar value & sqllogictest
- Loading branch information
Showing
5 changed files
with
156 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
mod buffer; | ||
mod catalog; | ||
mod common; | ||
pub mod database; | ||
pub mod error; | ||
mod database; | ||
mod error; | ||
mod execution; | ||
mod expression; | ||
mod optimizer; | ||
mod parser; | ||
mod planner; | ||
mod storage; | ||
|
||
pub use database::Database; | ||
pub use error::{BustubxError, BustubxResult}; | ||
pub use storage::Tuple; |
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,27 +1,45 @@ | ||
use bustubx::database::Database; | ||
use bustubx::error::BustubxError; | ||
use bustubx::Database; | ||
use bustubx::{BustubxError, Tuple}; | ||
use sqllogictest::{DBOutput, DefaultColumnType}; | ||
use tempfile::TempDir; | ||
|
||
pub struct Bustubx { | ||
pub struct BustubxDB { | ||
db: Database, | ||
tmp_dir: TempDir, | ||
} | ||
|
||
impl Bustubx { | ||
impl BustubxDB { | ||
pub fn new() -> Self { | ||
let tmp_dir = TempDir::new().unwrap(); | ||
let db = Database::new_on_disk(tmp_dir.path().to_str().unwrap()); | ||
Self { db, tmp_dir } | ||
let db = Database::new_temp(); | ||
Self { db } | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl sqllogictest::AsyncDB for &Bustubx { | ||
fn tuples_to_sqllogictest_string(tuples: Vec<Tuple>) -> Vec<Vec<String>> { | ||
todo!() | ||
} | ||
|
||
impl sqllogictest::DB for BustubxDB { | ||
type Error = BustubxError; | ||
type ColumnType = DefaultColumnType; | ||
|
||
async fn run(&mut self, sql: &str) -> Result<DBOutput<Self::ColumnType>, Self::Error> { | ||
todo!() | ||
fn run(&mut self, sql: &str) -> Result<DBOutput<Self::ColumnType>, Self::Error> { | ||
let is_query_sql = { | ||
let lower_sql = sql.trim_start().to_ascii_lowercase(); | ||
lower_sql.starts_with("select") | ||
}; | ||
let tuples = self.db.run(sql)?; | ||
if tuples.is_empty() { | ||
if is_query_sql { | ||
return Ok(DBOutput::Rows { | ||
types: vec![], | ||
rows: vec![], | ||
}); | ||
} else { | ||
return Ok(DBOutput::StatementComplete(0)); | ||
} | ||
} | ||
// TODO fix type count | ||
let types = vec![DefaultColumnType::Any; 3]; | ||
let rows = tuples_to_sqllogictest_string(tuples); | ||
Ok(DBOutput::Rows { types, rows }) | ||
} | ||
} |