-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refer to SparkSQL to implement Physical Select of CBO based on RBO. (#…
…118) * bench: added SQLite for comparative testing * feat: impl Memo of CBO * feat: impl Histogram of CBO * feat: add TableMeta of `ShowTable` * feat: impl Histogram load on `Memo::new` to calculate cost of `Expression` * feat: impl `AnalyzeTable` to build the histogram of load `Histogram` on `Memo::new` * feat: completed the integration of CBO into the optimizer(currently only single column index selection is supported) * perf: optimize row count estimation - use Count min sketch to estimate equivalence conditions - for more accurate row number estimation when the range condition intersects with the bucket range of the histogram, refer to BaikalDB * style: Histogram -> ColumnMeta * fix: the optimizer does not use CBO by default
- Loading branch information
Showing
97 changed files
with
3,497 additions
and
526 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ Cargo.lock | |
/hello_world | ||
/transaction | ||
|
||
query_bench_data/ | ||
kipsql_bench | ||
sqlite_bench |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
[package] | ||
name = "kip-sql" | ||
version = "0.0.1-alpha.8" | ||
version = "0.0.1-alpha.9" | ||
edition = "2021" | ||
authors = ["Kould <[email protected]>", "Xwg <[email protected]>"] | ||
description = "build the SQL layer of KipDB database" | ||
|
@@ -24,7 +24,6 @@ codegen_execute = ["dep:mlua"] | |
name = "query_bench" | ||
path = "benchmarks/query_benchmark.rs" | ||
harness = false | ||
required-features = ["codegen_execute"] | ||
|
||
[dependencies] | ||
sqlparser = "0.34.0" | ||
|
@@ -46,11 +45,14 @@ ahash = "0.8.3" | |
lazy_static = "1.4.0" | ||
comfy-table = "7.0.1" | ||
bytes = "1.5.0" | ||
kip_db = "0.1.2-alpha.21" | ||
kip_db = "0.1.2-alpha.23.fix5" | ||
rust_decimal = "1" | ||
csv = "1" | ||
regex = "1.10.2" | ||
clap = "4.4.11" | ||
rand = "0.8.5" | ||
dirs = "5.0.1" | ||
siphasher = { version = "0.3.11", features = ["serde"] } | ||
|
||
mlua = { version = "0.9.1", features = ["luajit", "vendored", "macros", "async"], optional = true } | ||
|
||
|
@@ -64,6 +66,9 @@ env_logger = "0.10" | |
paste = "^1.0" | ||
rstest = "0.17" | ||
tempfile = "3.0.7" | ||
rand_distr = "0.4.3" | ||
|
||
sqlite = "0.32.0" | ||
|
||
[workspace] | ||
members = [ | ||
|
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 +1 @@ | ||
nightly | ||
nightly-2024-01-18 |
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 crate::binder::{lower_case_name, split_name, BindError, Binder}; | ||
use crate::planner::operator::analyze::AnalyzeOperator; | ||
use crate::planner::operator::scan::ScanOperator; | ||
use crate::planner::operator::Operator; | ||
use crate::planner::LogicalPlan; | ||
use crate::storage::Transaction; | ||
use itertools::Itertools; | ||
use sqlparser::ast::ObjectName; | ||
use std::sync::Arc; | ||
|
||
impl<'a, T: Transaction> Binder<'a, T> { | ||
pub(crate) fn bind_analyze(&mut self, name: &ObjectName) -> Result<LogicalPlan, BindError> { | ||
let name = lower_case_name(name); | ||
let name = split_name(&name)?; | ||
let table_name = Arc::new(name.to_string()); | ||
|
||
let table_catalog = self | ||
.context | ||
.table(table_name.clone()) | ||
.cloned() | ||
.ok_or_else(|| BindError::InvalidTable(format!("bind table {}", name)))?; | ||
let columns = table_catalog | ||
.all_columns() | ||
.into_iter() | ||
.filter_map(|column| column.desc.is_index().then(|| column)) | ||
.collect_vec(); | ||
|
||
let scan_op = ScanOperator::build(table_name.clone(), &table_catalog); | ||
self.context | ||
.add_bind_table(table_name.clone(), table_catalog, None)?; | ||
|
||
let plan = LogicalPlan { | ||
operator: Operator::Analyze(AnalyzeOperator { | ||
table_name, | ||
columns, | ||
}), | ||
childrens: vec![scan_op], | ||
physical_option: None, | ||
}; | ||
Ok(plan) | ||
} | ||
} |
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
Oops, something went wrong.