Skip to content

Commit ad8f954

Browse files
committed
chore: codefmt
1 parent 10aa0e3 commit ad8f954

File tree

26 files changed

+169
-164
lines changed

26 files changed

+169
-164
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,15 @@ jobs:
2929
# as it is set as an "override" for current directory
3030

3131
- name: Run cargo check
32-
uses: actions-rs/cargo@v1
33-
with:
34-
command: check
32+
run: make cargo-check
3533

3634

3735
- name: Run cargo build
38-
uses: actions-rs/cargo@v1
39-
with:
40-
command: build
36+
run: make build
4137

4238

4339
- name: Run cargo test
44-
uses: actions-rs/cargo@v1
45-
with:
46-
command: test
47-
args: --all
40+
run: make test
4841
# 2
4942
fmt:
5043
name: Rust fmt
@@ -62,10 +55,7 @@ jobs:
6255
# as it is set as an "override" for current directory
6356

6457
- name: Run cargo fmt
65-
uses: actions-rs/cargo@v1
66-
with:
67-
command: fmt
68-
args: -- --check
58+
run: make fmt
6959
# 3
7060
e2e:
7161
name: Rust e2e sqllogictest
@@ -85,11 +75,8 @@ jobs:
8575
# `cargo check` command here will use installed `nightly`
8676
# as it is set as an "override" for current directory
8777

88-
- name: Run cargo run sqllogictest-test
89-
uses: actions-rs/cargo@v1
90-
with:
91-
command: run
92-
args: --bin sqllogictest-test --manifest-path ./tests/sqllogictest/Cargo.toml
78+
- name: Run sqllogictest suite
79+
run: make test-slt
9380
# 4
9481
wasm-tests:
9582
name: Wasm cargo tests
@@ -115,7 +102,7 @@ jobs:
115102
version: latest
116103

117104
- name: Run wasm-bindgen tests (wasm32 target)
118-
run: wasm-pack test --node -- --package kite_sql --lib
105+
run: make test-wasm
119106
# 5
120107
wasm-examples:
121108
name: Wasm examples (nodejs)
@@ -141,12 +128,10 @@ jobs:
141128
version: latest
142129

143130
- name: Build wasm package
144-
run: wasm-pack build --release --target nodejs
131+
run: make wasm-build
145132

146133
- name: Run wasm example scripts
147-
run: |
148-
node examples/wasm_hello_world.test.mjs
149-
node examples/wasm_index_usage.test.mjs
134+
run: make wasm-examples
150135
# 6
151136
native-examples:
152137
name: Native examples
@@ -160,8 +145,5 @@ jobs:
160145
toolchain: stable
161146
override: true
162147

163-
- name: Run hello_world example
164-
run: cargo run --example hello_world
165-
166-
- name: Run transaction example
167-
run: cargo run --example transaction
148+
- name: Run native examples
149+
run: make native-examples

Makefile

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@ CARGO ?= cargo
33
WASM_PACK ?= wasm-pack
44
SQLLOGIC_PATH ?= tests/slt/**/*.slt
55

6-
.PHONY: test test-wasm test-slt test-all wasm-build check tpcc
6+
.PHONY: test test-wasm test-slt test-all wasm-build check tpcc cargo-check build wasm-examples native-examples fmt clippy
77

88
## Run default Rust tests in the current environment (non-WASM).
99
test:
10-
$(CARGO) test
10+
$(CARGO) test --all
11+
12+
## Perform a `cargo check` across the workspace.
13+
cargo-check:
14+
$(CARGO) check
15+
16+
## Build the workspace artifacts (debug).
17+
build:
18+
$(CARGO) build
1119

1220
## Build the WebAssembly package (artifact goes to ./pkg).
1321
wasm-build:
1422
$(WASM_PACK) build --release --target nodejs
1523

1624
## Execute wasm-bindgen tests under Node.js (wasm32 target).
1725
test-wasm:
18-
$(WASM_PACK) test --node --release
26+
$(WASM_PACK) test --node -- --package kite_sql --lib
1927

2028
## Run the sqllogictest harness against the configured .slt suite.
2129
test-slt:
@@ -24,11 +32,27 @@ test-slt:
2432
## Convenience target to run every suite in sequence.
2533
test-all: test test-wasm test-slt
2634

27-
## Run formatting (check mode) and clippy linting together.
28-
check:
35+
## Run formatting (check mode) across the workspace.
36+
fmt:
2937
$(CARGO) fmt --all -- --check
38+
39+
## Execute clippy across all targets/features with warnings elevated to errors.
40+
clippy:
3041
$(CARGO) clippy --all-targets --all-features -- -D warnings
3142

43+
## Run formatting (check mode) and clippy linting together.
44+
check: fmt clippy
45+
3246
## Execute the TPCC workload example as a standalone command.
3347
tpcc:
3448
$(CARGO) run -p tpcc --release
49+
50+
## Run JavaScript-based Wasm example scripts.
51+
wasm-examples:
52+
node examples/wasm_hello_world.test.mjs
53+
node examples/wasm_index_usage.test.mjs
54+
55+
## Run the native (non-Wasm) example binaries.
56+
native-examples:
57+
$(CARGO) run --example hello_world
58+
$(CARGO) run --example transaction

benchmarks/query_benchmark.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use sqlite::Error;
2222
use std::fs;
2323
use std::path::Path;
2424

25-
const QUERY_BENCH_KITE_SQL_PATH: &'static str = "./kitesql_bench";
26-
const QUERY_BENCH_SQLITE_PATH: &'static str = "./sqlite_bench";
25+
const QUERY_BENCH_KITE_SQL_PATH: &str = "./kitesql_bench";
26+
const QUERY_BENCH_SQLITE_PATH: &str = "./sqlite_bench";
2727
const TABLE_ROW_NUM: u64 = 200_000;
2828

2929
fn query_cases() -> Vec<(&'static str, &'static str)> {
@@ -62,9 +62,9 @@ fn init_kitesql_query_bench() -> Result<(), DatabaseError> {
6262
}
6363

6464
fn init_sqlite_query_bench() -> Result<(), Error> {
65-
let connection = sqlite::open(QUERY_BENCH_SQLITE_PATH.to_owned())?;
65+
let connection = sqlite::open(QUERY_BENCH_SQLITE_PATH)?;
6666

67-
let _ = connection.execute("create table t1 (c1 int primary key, c2 int)")?;
67+
connection.execute("create table t1 (c1 int primary key, c2 int)")?;
6868

6969
let pb = ProgressBar::new(TABLE_ROW_NUM);
7070
pb.set_style(
@@ -73,7 +73,7 @@ fn init_sqlite_query_bench() -> Result<(), Error> {
7373
.unwrap(),
7474
);
7575
for i in 0..TABLE_ROW_NUM {
76-
let _ = connection.execute(format!("insert into t1 values({}, {})", i, i + 1))?;
76+
connection.execute(format!("insert into t1 values({i}, {})", i + 1).as_str())?;
7777
pb.set_position(i + 1);
7878
}
7979
pb.finish_with_message("Insert completed!");
@@ -91,16 +91,14 @@ fn path_exists_and_is_directory(path: &str) -> bool {
9191
fn query_on_execute(c: &mut Criterion) {
9292
if !Path::new(QUERY_BENCH_SQLITE_PATH).exists() {
9393
println!(
94-
"SQLITE: The table is not initialized and data insertion is started. => {}",
95-
TABLE_ROW_NUM
94+
"SQLITE: The table is not initialized and data insertion is started. => {TABLE_ROW_NUM}"
9695
);
9796

9897
init_sqlite_query_bench().unwrap();
9998
}
10099
if !path_exists_and_is_directory(QUERY_BENCH_KITE_SQL_PATH) {
101100
println!(
102-
"KiteSQL: The table is not initialized and data insertion is started. => {}",
103-
TABLE_ROW_NUM
101+
"KiteSQL: The table is not initialized and data insertion is started. => {TABLE_ROW_NUM}"
104102
);
105103

106104
init_kitesql_query_bench().unwrap();
@@ -111,16 +109,18 @@ fn query_on_execute(c: &mut Criterion) {
111109
println!("Table initialization completed");
112110

113111
for (name, case) in query_cases() {
114-
c.bench_function(format!("KiteSQL: {} by '{}'", name, case).as_str(), |b| {
112+
let kite_label = format!("KiteSQL: {name} by '{case}'");
113+
c.bench_function(&kite_label, |b| {
115114
b.iter(|| {
116115
for tuple in database.run(case).unwrap() {
117116
let _ = tuple.unwrap();
118117
}
119118
})
120119
});
121120

122-
let connection = sqlite::open(QUERY_BENCH_SQLITE_PATH.to_owned()).unwrap();
123-
c.bench_function(format!("SQLite: {} by '{}'", name, case).as_str(), |b| {
121+
let connection = sqlite::open(QUERY_BENCH_SQLITE_PATH).unwrap();
122+
let sqlite_label = format!("SQLite: {name} by '{case}'");
123+
c.bench_function(&sqlite_label, |b| {
124124
b.iter(|| {
125125
for row in connection.prepare(case).unwrap() {
126126
let _ = row.unwrap();

src/bin/server.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use futures::stream;
1818
use kite_sql::db::{DBTransaction, DataBaseBuilder, Database, ResultIter};
1919
use kite_sql::errors::DatabaseError;
2020
use kite_sql::storage::rocksdb::RocksStorage;
21-
use kite_sql::types::tuple::{Schema, SchemaRef, Tuple};
21+
use kite_sql::types::tuple::{SchemaRef, Tuple};
2222
use kite_sql::types::LogicalType;
2323
use log::{error, info, LevelFilter};
2424
use parking_lot::Mutex;
@@ -172,7 +172,10 @@ impl SimpleQueryHandler for SessionBackend {
172172
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
173173
guard.replace(TransactionPtr(
174174
Box::leak(Box::<DBTransaction<'static, RocksStorage>>::new(unsafe {
175-
transmute(transaction)
175+
transmute::<
176+
DBTransaction<'_, RocksStorage>,
177+
DBTransaction<'static, RocksStorage>,
178+
>(transaction)
176179
}))
177180
.into(),
178181
));
@@ -371,7 +374,7 @@ async fn main() {
371374
tokio::select! {
372375
res = server_run(listener,factory) => {
373376
if let Err(err) = res {
374-
error!("[Listener][Failed To Accept]: {}", err);
377+
error!("[Listener][Failed To Accept]: {err}");
375378
}
376379
}
377380
_ = quit() => info!("Bye!")
@@ -388,7 +391,7 @@ async fn server_run(
388391

389392
tokio::spawn(async move {
390393
if let Err(err) = process_socket(incoming_socket.0, None, factory_ref).await {
391-
error!("Failed To Process: {}", err);
394+
error!("Failed To Process: {err}");
392395
}
393396
});
394397
}

src/binder/create_table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ mod tests {
212212
Operator::CreateTable(op) => {
213213
assert_eq!(op.table_name.as_ref(), "t1");
214214
assert_eq!(op.columns[0].name(), "id");
215-
assert_eq!(op.columns[0].nullable(), false);
215+
assert!(!op.columns[0].nullable());
216216
assert_eq!(
217217
op.columns[0].desc(),
218218
&ColumnDesc::new(LogicalType::Integer, Some(0), false, None)?
219219
);
220220
assert_eq!(op.columns[1].name(), "name");
221-
assert_eq!(op.columns[1].nullable(), true);
221+
assert!(op.columns[1].nullable());
222222
assert_eq!(
223223
op.columns[1].desc(),
224224
&ColumnDesc::new(

src/binder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ pub mod test {
581581
);
582582
let stmt = crate::parser::parse_sql(sql)?;
583583

584-
Ok(binder.bind(&stmt[0])?)
584+
binder.bind(&stmt[0])
585585
}
586586

587587
pub(crate) fn column_id_by_name(&self, name: &str) -> &ColumnId {

src/binder/select.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,27 +1213,27 @@ mod tests {
12131213
let table_states = build_t1_table()?;
12141214

12151215
let plan_1 = table_states.plan("select * from t1")?;
1216-
println!("just_col:\n {:#?}", plan_1);
1216+
println!("just_col:\n {plan_1:#?}");
12171217
let plan_2 = table_states.plan("select t1.c1, t1.c2 from t1")?;
1218-
println!("table_with_col:\n {:#?}", plan_2);
1218+
println!("table_with_col:\n {plan_2:#?}");
12191219
let plan_3 = table_states.plan("select t1.c1, t1.c2 from t1 where c1 > 2")?;
1220-
println!("table_with_col_and_c1_compare_constant:\n {:#?}", plan_3);
1220+
println!("table_with_col_and_c1_compare_constant:\n {plan_3:#?}");
12211221
let plan_4 = table_states.plan("select t1.c1, t1.c2 from t1 where c1 > c2")?;
1222-
println!("table_with_col_and_c1_compare_c2:\n {:#?}", plan_4);
1222+
println!("table_with_col_and_c1_compare_c2:\n {plan_4:#?}");
12231223
let plan_5 = table_states.plan("select avg(t1.c1) from t1")?;
1224-
println!("table_with_col_and_c1_avg:\n {:#?}", plan_5);
1224+
println!("table_with_col_and_c1_avg:\n {plan_5:#?}");
12251225
let plan_6 = table_states.plan("select t1.c1, t1.c2 from t1 where (t1.c1 - t1.c2) > 1")?;
1226-
println!("table_with_col_nested:\n {:#?}", plan_6);
1226+
println!("table_with_col_nested:\n {plan_6:#?}");
12271227

12281228
let plan_7 = table_states.plan("select * from t1 limit 1")?;
1229-
println!("limit:\n {:#?}", plan_7);
1229+
println!("limit:\n {plan_7:#?}");
12301230

12311231
let plan_8 = table_states.plan("select * from t1 offset 2")?;
1232-
println!("offset:\n {:#?}", plan_8);
1232+
println!("offset:\n {plan_8:#?}");
12331233

12341234
let plan_9 =
12351235
table_states.plan("select c1, c3 from t1 inner join t2 on c1 = c3 and c1 > 1")?;
1236-
println!("join:\n {:#?}", plan_9);
1236+
println!("join:\n {plan_9:#?}");
12371237

12381238
Ok(())
12391239
}

src/catalog/table.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,19 +309,19 @@ mod tests {
309309
let col_catalogs = vec![col0, col1];
310310
let table_catalog = TableCatalog::new("test".to_string().into(), col_catalogs).unwrap();
311311

312-
assert_eq!(table_catalog.contains_column("a"), true);
313-
assert_eq!(table_catalog.contains_column("b"), true);
314-
assert_eq!(table_catalog.contains_column("c"), false);
312+
assert!(table_catalog.contains_column("a"));
313+
assert!(table_catalog.contains_column("b"));
314+
assert!(!table_catalog.contains_column("c"));
315315

316316
let col_a_id = table_catalog.get_column_id_by_name("a").unwrap();
317317
let col_b_id = table_catalog.get_column_id_by_name("b").unwrap();
318318
assert!(col_a_id < col_b_id);
319319

320-
let column_catalog = table_catalog.get_column_by_id(&col_a_id).unwrap();
320+
let column_catalog = table_catalog.get_column_by_id(col_a_id).unwrap();
321321
assert_eq!(column_catalog.name(), "a");
322322
assert_eq!(*column_catalog.datatype(), LogicalType::Integer,);
323323

324-
let column_catalog = table_catalog.get_column_by_id(&col_b_id).unwrap();
324+
let column_catalog = table_catalog.get_column_by_id(col_b_id).unwrap();
325325
assert_eq!(column_catalog.name(), "b");
326326
assert_eq!(*column_catalog.datatype(), LogicalType::Boolean,);
327327
}

src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ pub(crate) mod test {
544544
let database = DataBaseBuilder::path(temp_dir.path()).build()?;
545545
let mut transaction = database.storage.transaction()?;
546546

547-
build_table(&database.state.table_cache(), &mut transaction)?;
547+
build_table(database.state.table_cache(), &mut transaction)?;
548548
transaction.commit()?;
549549

550550
for result in database.run("select * from t1")? {

src/execution/dml/copy_from_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ mod tests {
161161
let csv = "1,1.5,one\n2,2.5,two\n";
162162

163163
let mut file = tempfile::NamedTempFile::new().expect("failed to create temp file");
164-
write!(file, "{}", csv).expect("failed to write file");
164+
write!(file, "{csv}").expect("failed to write file");
165165

166166
let columns = vec![
167167
ColumnRef::from(ColumnCatalog::direct_new(

0 commit comments

Comments
 (0)