Skip to content

Commit c769347

Browse files
authored
refactor: stable kitesql (#292)
* refactor: stable kitesql * chore: fix nested_loop_join unit test
1 parent da2b5c5 commit c769347

Some content is hidden

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

85 files changed

+1860
-1852
lines changed

Cargo.lock

Lines changed: 76 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "kite_sql"
5-
version = "0.1.2"
5+
version = "0.1.3"
66
edition = "2021"
77
authors = ["Kould <[email protected]>", "Xwg <[email protected]>"]
88
description = "SQL as a Function for Rust"
@@ -60,6 +60,8 @@ sqlparser = { version = "0.34", features = ["serde"] }
6060
thiserror = { version = "1" }
6161
typetag = { version = "0.2" }
6262
ulid = { version = "1", features = ["serde"] }
63+
genawaiter = { version = "0.99" }
64+
rand = { version = "0.8" }
6365

6466
# Feature: net
6567
async-trait = { version = "0.1", optional = true }

kite_sql_serde_macros/src/reference_serialization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub(crate) fn handle(ast: DeriveInput) -> Result<TokenStream, Error> {
9292

9393
let field_name = field_opts
9494
.ident
95-
.unwrap_or_else(|| Ident::new(&format!("field_{}", i), Span::call_site()));
95+
.unwrap_or_else(|| Ident::new(&format!("field_{i}"), Span::call_site()));
9696
let ty = process_type(&field_opts.ty);
9797

9898
encode_fields.push(quote! {
@@ -155,7 +155,7 @@ pub(crate) fn handle(ast: DeriveInput) -> Result<TokenStream, Error> {
155155

156156
let field_name = field_opts
157157
.ident
158-
.unwrap_or_else(|| Ident::new(&format!("field_{}", i), Span::call_site()));
158+
.unwrap_or_else(|| Ident::new(&format!("field_{i}"), Span::call_site()));
159159
let ty = process_type(&field_opts.ty);
160160

161161
encode_fields.push(quote! {

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2024-10-10
1+
stable

src/binder/aggregate.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
8383

8484
return_orderby.push(SortField::new(
8585
expr,
86-
asc.map_or(true, |asc| asc),
87-
nulls_first.map_or(false, |first| first),
86+
asc.is_none_or(|asc| asc),
87+
nulls_first.is_some_and(|first| first),
8888
));
8989
}
9090
Some(return_orderby)
@@ -251,8 +251,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
251251

252252
if !group_raw_exprs.iter().contains(&expr) {
253253
return Err(DatabaseError::AggMiss(format!(
254-
"`{}` must appear in the GROUP BY clause or be used in an aggregate function",
255-
expr
254+
"`{expr}` must appear in the GROUP BY clause or be used in an aggregate function"
256255
)));
257256
}
258257
}
@@ -306,12 +305,9 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
306305
return Ok(());
307306
}
308307

309-
Err(DatabaseError::AggMiss(
310-
format!(
311-
"expression '{}' must appear in the GROUP BY clause or be used in an aggregate function",
312-
expr
313-
)
314-
))
308+
Err(DatabaseError::AggMiss(format!(
309+
"expression '{expr}' must appear in the GROUP BY clause or be used in an aggregate function"
310+
)))
315311
}
316312
ScalarExpression::ColumnRef { .. } | ScalarExpression::Alias { .. } => {
317313
if self.context.group_by_exprs.contains(expr) {
@@ -321,12 +317,9 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
321317
return self.validate_having_orderby(expr.unpack_alias_ref());
322318
}
323319

324-
Err(DatabaseError::AggMiss(
325-
format!(
326-
"expression '{}' must appear in the GROUP BY clause or be used in an aggregate function",
327-
expr
328-
)
329-
))
320+
Err(DatabaseError::AggMiss(format!(
321+
"expression '{expr}' must appear in the GROUP BY clause or be used in an aggregate function"
322+
)))
330323
}
331324

332325
ScalarExpression::TypeCast { expr, .. } => self.validate_having_orderby(expr),

src/binder/alter_table.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
4444
if_not_exists: *if_not_exists,
4545
column,
4646
}),
47-
Childrens::Only(plan),
47+
Childrens::Only(Box::new(plan)),
4848
)
4949
}
5050
AlterTableOperation::DropColumn {
@@ -61,13 +61,12 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
6161
if_exists: *if_exists,
6262
column_name,
6363
}),
64-
Childrens::Only(plan),
64+
Childrens::Only(Box::new(plan)),
6565
)
6666
}
6767
op => {
6868
return Err(DatabaseError::UnsupportedStmt(format!(
69-
"AlertOperation: {:?}",
70-
op
69+
"AlertOperation: {op:?}"
7170
)))
7271
}
7372
};

src/binder/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
3232
table_name,
3333
index_metas,
3434
}),
35-
Childrens::Only(scan_op),
35+
Childrens::Only(Box::new(scan_op)),
3636
))
3737
}
3838
}

src/binder/copy.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
9090
CopyTarget::File { filename } => filename.into(),
9191
t => {
9292
return Err(DatabaseError::UnsupportedStmt(format!(
93-
"copy target: {:?}",
94-
t
93+
"copy target: {t:?}"
9594
)))
9695
}
9796
},
@@ -105,7 +104,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
105104
target: ext_source,
106105
schema_ref,
107106
}),
108-
Childrens::Only(TableScanOperator::build(table_name, table, false)),
107+
Childrens::Only(Box::new(TableScanOperator::build(table_name, table, false))),
109108
))
110109
} else {
111110
// COPY <dest_table> FROM <source_file>
@@ -140,7 +139,7 @@ impl FileFormat {
140139
CopyOption::Header(b) => header = *b,
141140
CopyOption::Quote(c) => quote = *c,
142141
CopyOption::Escape(c) => escape = Some(*c),
143-
o => panic!("unsupported copy option: {:?}", o),
142+
o => panic!("unsupported copy option: {o:?}"),
144143
}
145144
}
146145
FileFormat::Csv {

src/binder/create_index.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
4646
ScalarExpression::ColumnRef { column, .. } => columns.push(column),
4747
expr => {
4848
return Err(DatabaseError::UnsupportedStmt(format!(
49-
"'CREATE INDEX' by {}",
50-
expr
49+
"'CREATE INDEX' by {expr}"
5150
)))
5251
}
5352
}
@@ -61,7 +60,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
6160
if_not_exists,
6261
ty,
6362
}),
64-
Childrens::Only(plan),
63+
Childrens::Only(Box::new(plan)),
6564
))
6665
}
6766
}

src/binder/create_table.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
7676
}
7777
constraint => {
7878
return Err(DatabaseError::UnsupportedStmt(format!(
79-
"`CreateTable` does not currently support this constraint: {:?}",
80-
constraint
79+
"`CreateTable` does not currently support this constraint: {constraint:?}"
8180
)))?
8281
}
8382
}
@@ -145,8 +144,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
145144
}
146145
option => {
147146
return Err(DatabaseError::UnsupportedStmt(format!(
148-
"`Column` does not currently support this option: {:?}",
149-
option
147+
"`Column` does not currently support this option: {option:?}"
150148
)))
151149
}
152150
}

0 commit comments

Comments
 (0)