Skip to content

Commit 512690f

Browse files
authored
Refactor column storage to row storage (#49)
* refactor: clear useless code and dependencies * feat: impl eval_column for tp * feat: impl storage for tp * feat: impl dml(insert/values/seq_scan/project) and ddl(create) for tp * feat: impl dml(filter) for tp * feat: impl dml(sort) for tp * feat: impl dml(limit) for tp * feat: `SeqScan` supports Projection and Limit pushdown * style: new dql * feat: impl dql(hash_join) for tp * feat: impl `on filter` for dql(hash_join) * feat: impl `repeat join` for dql(hash_join) * style: remove ap * perf: use Arc pointers to encapsulate `DataValue` and `ColumnCatalog` to avoid copy loss * docs: rewrite README.md and fix `hash_join` bug * style: version reset
1 parent 915f01b commit 512690f

109 files changed

Lines changed: 2091 additions & 4346 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,33 @@
22

33
[package]
44
name = "kip-sql"
5-
version = "0.1.0"
5+
version = "0.0.1-alpha.0"
66
edition = "2021"
77

88
[lib]
99
doctest = false
1010

1111
[dependencies]
12-
log = "^0.4"
1312
sqlparser = "0.34.0"
1413
thiserror = "1"
1514
parking_lot = "0.12.1"
1615
itertools = "0.10"
1716
sqllogictest = "0.11.1"
18-
rust_decimal = "1"
19-
paste = "1.0.11"
2017
tracing = "0.1.37"
21-
pin-project = "1.1.0"
2218
chrono = "0.4.26"
23-
roaring = "0.10.1"
24-
educe = "0.4"
25-
num-traits = "0.2"
26-
num-derive = "0.3"
27-
anyhow = "1.0.71"
2819
tokio = { version = "1.28.2", features = ["full"] }
29-
tokio-process = "0.2.5"
3020
serde = { version = "1", features = ["derive", "rc"] }
3121
serde_json = "1"
3222
async-trait = "0.1.68"
3323
integer-encoding = "3.0.4"
34-
arrow = { version = "28", features = ["prettyprint", "simd"] }
3524
strum_macros = "0.24"
3625
ordered-float = "3.0"
3726
petgraph = "0.6.3"
3827
futures-async-stream = "0.2.6"
39-
async-channel = "1.8.0"
40-
async-backtrace = "0.2.6"
4128
futures = "0.3.25"
42-
futures-lite = "1.12.0"
4329
ahash = "0.8.3"
4430
lazy_static = "1.4.0"
31+
comfy-table = "7.0.1"
4532

4633
[dev-dependencies]
4734
tokio-test = "0.4.2"

README.md

Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,84 @@
11
# KipSQL
22

3-
> build the SQL layer of KipDB database.
3+
> Lightweight SQL calculation engine, as the SQL layer of KipDB, implemented with TalentPlan's TinySQL as the reference standard
44
5+
### Architecture
6+
![architecture](./static/images/architecture.png)
57

6-
> 目前处于探索阶段
7-
轻量级SQL计算引擎,作为KipDB的SQL层,以TalentPlan的TinySQL作为参考标准进行实现
8-
9-
## Example
10-
```rust
11-
let kipsql = Database::new_on_mem();
12-
13-
let _ = kipsql.run("create table t1 (a int, b int)").await?;
14-
let _ = kipsql.run("create table t2 (c int, d int)").await?;
15-
let _ = kipsql.run("insert into t1 (b, a) values (1, 1), (3, 3), (5, 4)").await?;
16-
let _ = kipsql.run("insert into t2 (d, c) values (1, 2), (2, 3), (5, 6)").await?;
17-
18-
println!("full t1:");
19-
let vec_batch_full_fields_t1 = kipsql.run("select * from t1").await?;
20-
print_batches(&vec_batch_full_fields_t1)?;
21-
22-
println!("full t2:");
23-
let vec_batch_full_fields_t2 = kipsql.run("select * from t2").await?;
24-
print_batches(&vec_batch_full_fields_t2)?;
25-
26-
println!("projection_and_filter:");
27-
let vec_batch_projection_a = kipsql.run("select a from t1 where a <= b").await?;
28-
print_batches(&vec_batch_projection_a)?;
29-
30-
println!("projection_and_sort:");
31-
let vec_batch_projection_a = kipsql.run("select a from t1 order by a").await?;
32-
print_batches(&vec_batch_projection_a)?;
33-
34-
println!("limit:");
35-
let vec_batch_limit=kipsql.run("select * from t1 limit 1 offset 1").await?;
36-
print_batches(&vec_batch_limit)?;
37-
38-
println!("inner join:");
39-
let vec_batch_inner_join = kipsql.run("select * from t1 inner join t2 on a = c").await?;
40-
print_batches(&vec_batch_inner_join)?;
8+
### Get Started
9+
Install rust toolchain first.
10+
```
11+
cargo run
12+
```
13+
test command
14+
```mysql
15+
create table t1 (a int, b int);
4116

42-
println!("left join:");
43-
let vec_batch_left_join = kipsql.run("select * from t1 left join t2 on a = c").await?;
44-
print_batches(&vec_batch_left_join)?;
17+
insert into t1 (a, b) values (1, 1), (5, 3), (5, 2);
4518

46-
println!("right join:");
47-
let vec_batch_right_join = kipsql.run("select * from t1 right join t2 on a = c and a > 1").await?;
48-
print_batches(&vec_batch_right_join)?;
19+
select * from t1;
4920

50-
println!("full join:");
51-
let vec_batch_full_join = kipsql.run("select d, b from t1 full join t2 on a = c and a > 1").await?;
52-
print_batches(&vec_batch_full_join)?;
21+
select * from t1 order by a asc nulls first
5322
```
5423

24+
![demo](./static/images/demo.png)
25+
5526
### Features
56-
- Select
57-
- Filter
58-
- Limit
59-
- Sort
60-
- Projection
61-
- TableScan
62-
- Join (HashJoin)
63-
- Inner
64-
- Left
65-
- Right
66-
- Full
67-
- Insert
68-
- CreateTable
27+
- DDL
28+
- Create
29+
- [x] CreateTable
30+
- [ ] CreateIndex
31+
- Drop
32+
- DQL
33+
- [x] Select
34+
- [x] Where
35+
- [ ] Distinct
36+
- [ ] Aggregation: count()/sum()/avg()/min()/max()
37+
- [ ] Subquery
38+
- [x] Join: Inner/Left/Right/Full Cross(x)
39+
- [ ] Group By
40+
- [ ] Having
41+
- [x] Order By
42+
- [x] Limit
43+
- DML
44+
- [x] Insert
45+
- [ ] Update
46+
- [ ] Delete
47+
- DataTypes
48+
- Invalid
49+
- SqlNull
50+
- Boolean
51+
- Tinyint
52+
- UTinyint
53+
- Smallint
54+
- USmallint
55+
- Integer
56+
- UInteger
57+
- Bigint
58+
- UBigint
59+
- Float
60+
- Double
61+
- Varchar
62+
- Optimizer rules
63+
- Limit Project Transpose
64+
- Eliminate Limits
65+
- Push Limit Through Join
66+
- Push Limit Into Scan
67+
- Combine Filters
68+
- Column Pruning
69+
- Collapse Project
70+
- Executors
71+
- [x] CreateTable
72+
- [x] SeqScan
73+
- [ ] IndexScan
74+
- [x] Filter
75+
- [x] Project
76+
- [x] Limit
77+
- [x] Hash Join
78+
- [x] Insert
79+
- [x] Values
80+
- [ ] Update
81+
- [ ] Delete
6982

7083
### Thanks For
7184
- [Fedomn/sqlrs](https://github.com/Fedomn/sqlrs): 主要参考资料,Optimizer、Executor均参考自sqlrs的设计

0 commit comments

Comments
 (0)