Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "kite_sql"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
authors = ["Kould <[email protected]>", "Xwg <[email protected]>"]
description = "SQL as a Function for Rust"
Expand Down Expand Up @@ -60,6 +60,8 @@ sqlparser = { version = "0.34", features = ["serde"] }
thiserror = { version = "1" }
typetag = { version = "0.2" }
ulid = { version = "1", features = ["serde"] }
genawaiter = { version = "0.99" }
rand = { version = "0.8" }

# Feature: net
async-trait = { version = "0.1", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions kite_sql_serde_macros/src/reference_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub(crate) fn handle(ast: DeriveInput) -> Result<TokenStream, Error> {

let field_name = field_opts
.ident
.unwrap_or_else(|| Ident::new(&format!("field_{}", i), Span::call_site()));
.unwrap_or_else(|| Ident::new(&format!("field_{i}"), Span::call_site()));
let ty = process_type(&field_opts.ty);

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

let field_name = field_opts
.ident
.unwrap_or_else(|| Ident::new(&format!("field_{}", i), Span::call_site()));
.unwrap_or_else(|| Ident::new(&format!("field_{i}"), Span::call_site()));
let ty = process_type(&field_opts.ty);

encode_fields.push(quote! {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-10-10
stable
25 changes: 9 additions & 16 deletions src/binder/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>

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

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

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

Err(DatabaseError::AggMiss(
format!(
"expression '{}' must appear in the GROUP BY clause or be used in an aggregate function",
expr
)
))
Err(DatabaseError::AggMiss(format!(
"expression '{expr}' must appear in the GROUP BY clause or be used in an aggregate function"
)))
}

ScalarExpression::TypeCast { expr, .. } => self.validate_having_orderby(expr),
Expand Down
7 changes: 3 additions & 4 deletions src/binder/alter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
if_not_exists: *if_not_exists,
column,
}),
Childrens::Only(plan),
Childrens::Only(Box::new(plan)),
)
}
AlterTableOperation::DropColumn {
Expand All @@ -61,13 +61,12 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
if_exists: *if_exists,
column_name,
}),
Childrens::Only(plan),
Childrens::Only(Box::new(plan)),
)
}
op => {
return Err(DatabaseError::UnsupportedStmt(format!(
"AlertOperation: {:?}",
op
"AlertOperation: {op:?}"
)))
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/binder/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
table_name,
index_metas,
}),
Childrens::Only(scan_op),
Childrens::Only(Box::new(scan_op)),
))
}
}
7 changes: 3 additions & 4 deletions src/binder/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
CopyTarget::File { filename } => filename.into(),
t => {
return Err(DatabaseError::UnsupportedStmt(format!(
"copy target: {:?}",
t
"copy target: {t:?}"
)))
}
},
Expand All @@ -105,7 +104,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
target: ext_source,
schema_ref,
}),
Childrens::Only(TableScanOperator::build(table_name, table, false)),
Childrens::Only(Box::new(TableScanOperator::build(table_name, table, false))),
))
} else {
// COPY <dest_table> FROM <source_file>
Expand Down Expand Up @@ -140,7 +139,7 @@ impl FileFormat {
CopyOption::Header(b) => header = *b,
CopyOption::Quote(c) => quote = *c,
CopyOption::Escape(c) => escape = Some(*c),
o => panic!("unsupported copy option: {:?}", o),
o => panic!("unsupported copy option: {o:?}"),
}
}
FileFormat::Csv {
Expand Down
5 changes: 2 additions & 3 deletions src/binder/create_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
ScalarExpression::ColumnRef { column, .. } => columns.push(column),
expr => {
return Err(DatabaseError::UnsupportedStmt(format!(
"'CREATE INDEX' by {}",
expr
"'CREATE INDEX' by {expr}"
)))
}
}
Expand All @@ -61,7 +60,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
if_not_exists,
ty,
}),
Childrens::Only(plan),
Childrens::Only(Box::new(plan)),
))
}
}
6 changes: 2 additions & 4 deletions src/binder/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
}
constraint => {
return Err(DatabaseError::UnsupportedStmt(format!(
"`CreateTable` does not currently support this constraint: {:?}",
constraint
"`CreateTable` does not currently support this constraint: {constraint:?}"
)))?
}
}
Expand Down Expand Up @@ -145,8 +144,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
}
option => {
return Err(DatabaseError::UnsupportedStmt(format!(
"`Column` does not currently support this option: {:?}",
option
"`Column` does not currently support this option: {option:?}"
)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/binder/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
table_name,
primary_keys,
}),
Childrens::Only(plan),
Childrens::Only(Box::new(plan)),
))
} else {
unreachable!("only table")
Expand Down
5 changes: 4 additions & 1 deletion src/binder/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use crate::types::value::DataValue;

impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A> {
pub(crate) fn bind_explain(&mut self, plan: LogicalPlan) -> Result<LogicalPlan, DatabaseError> {
Ok(LogicalPlan::new(Operator::Explain, Childrens::Only(plan)))
Ok(LogicalPlan::new(
Operator::Explain,
Childrens::Only(Box::new(plan)),
))
}
}
5 changes: 2 additions & 3 deletions src/binder/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ impl<'a, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'a, '_, T
| BinaryOperator::Or
| BinaryOperator::Xor => LogicalType::Boolean,
BinaryOperator::StringConcat => LogicalType::Varchar(None, CharLengthUnits::Characters),
op => return Err(DatabaseError::UnsupportedStmt(format!("{}", op))),
op => return Err(DatabaseError::UnsupportedStmt(format!("{op}"))),
};

Ok(ScalarExpression::Binary {
Expand Down Expand Up @@ -504,8 +504,7 @@ impl<'a, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'a, '_, T
FunctionArgExpr::Wildcard => args.push(Self::wildcard_expr()),
expr => {
return Err(DatabaseError::UnsupportedStmt(format!(
"function arg: {:#?}",
expr
"function arg: {expr:#?}"
)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/binder/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
is_overwrite,
is_mapping_by_name,
}),
Childrens::Only(values_plan),
Childrens::Only(Box::new(values_plan)),
))
}

Expand Down
3 changes: 1 addition & 2 deletions src/binder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ impl<'a, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'a, '
right,
} => self.bind_set_operation(op, set_quantifier, left, right),
expr => Err(DatabaseError::UnsupportedStmt(format!(
"set expression: {:?}",
expr
"set expression: {expr:?}"
))),
}
}
Expand Down
Loading
Loading