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
85 changes: 49 additions & 36 deletions Cargo.lock

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

24 changes: 22 additions & 2 deletions kite_sql_serde_macros/src/reference_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ fn process_type(ty: &Type) -> TokenStream {
}
}
}
"BTreeMap" => {
if let PathArguments::AngleBracketed(AngleBracketedGenericArguments {
args, ..
}) = &path.segments.last().unwrap().arguments
{
let mut iter = args.iter();
if let (
Some(GenericArgument::Type(inner_ty_0)),
Some(GenericArgument::Type(inner_ty_1)),
) = (iter.next(), iter.next())
{
let inner_processed_0 = process_type(inner_ty_0);
let inner_processed_1 = process_type(inner_ty_1);

return quote! {
#ident::<#inner_processed_0, #inner_processed_1>
};
}
}
}
_ => {}
}

Expand All @@ -72,7 +92,7 @@ pub(crate) fn handle(ast: DeriveInput) -> Result<TokenStream, Error> {

let field_name = field_opts
.ident
.unwrap_or_else(|| Ident::new(&format!("filed_{}", 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 @@ -135,7 +155,7 @@ pub(crate) fn handle(ast: DeriveInput) -> Result<TokenStream, Error> {

let field_name = field_opts
.ident
.unwrap_or_else(|| Ident::new(&format!("filed_{}", 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
4 changes: 2 additions & 2 deletions src/binder/alter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
if_not_exists,
column_def,
} => {
let plan = TableScanOperator::build(table_name.clone(), table);
let plan = TableScanOperator::build(table_name.clone(), table, true);
let column = self.bind_column(column_def, None)?;

if !is_valid_identifier(column.name()) {
Expand All @@ -52,7 +52,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
if_exists,
..
} => {
let plan = TableScanOperator::build(table_name.clone(), table);
let plan = TableScanOperator::build(table_name.clone(), table, true);
let column_name = column_name.value.clone();

LogicalPlan::new(
Expand Down
2 changes: 1 addition & 1 deletion src/binder/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
.ok_or(DatabaseError::TableNotFound)?;
let index_metas = table.indexes.clone();

let scan_op = TableScanOperator::build(table_name.clone(), table);
let scan_op = TableScanOperator::build(table_name.clone(), table, false);
Ok(LogicalPlan::new(
Operator::Analyze(AnalyzeOperator {
table_name,
Expand Down
2 changes: 1 addition & 1 deletion src/binder/copy.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>
target: ext_source,
schema_ref,
}),
Childrens::Only(TableScanOperator::build(table_name, table)),
Childrens::Only(TableScanOperator::build(table_name, table, false)),
))
} else {
// COPY <dest_table> FROM <source_file>
Expand Down
2 changes: 1 addition & 1 deletion src/binder/create_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
.source_and_bind(table_name.clone(), None, None, false)?
.ok_or(DatabaseError::SourceNotFound)?;
let plan = match source {
Source::Table(table) => TableScanOperator::build(table_name.clone(), table),
Source::Table(table) => TableScanOperator::build(table_name.clone(), table, true),
Source::View(view) => LogicalPlan::clone(&view.plan),
};
let mut columns = Vec::with_capacity(exprs.len());
Expand Down
2 changes: 1 addition & 1 deletion src/binder/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'_, '_, T, A>
.iter()
.map(|(_, column)| column.clone())
.collect_vec();
let mut plan = TableScanOperator::build(table_name.clone(), table);
let mut plan = TableScanOperator::build(table_name.clone(), table, true);

if let Some(alias_idents) = alias_idents {
plan =
Expand Down
3 changes: 1 addition & 2 deletions src/binder/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,12 @@ impl<'a, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'a, '_, T
if args.len() != 1 {
return Err(DatabaseError::MisMatch("number of avg() parameters", "1"));
}
let ty = args[0].return_type();

return Ok(ScalarExpression::AggCall {
distinct: func.distinct,
kind: AggKind::Avg,
args,
ty,
ty: LogicalType::Double,
});
}
"if" => {
Expand Down
13 changes: 13 additions & 0 deletions src/binder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ pub struct Binder<'a, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>>
context: BinderContext<'a, T>,
table_schema_buf: HashMap<TableName, Option<SchemaOutput>>,
args: &'a A,
with_pk: Option<TableName>,
pub(crate) parent: Option<&'b Binder<'a, 'b, T, A>>,
}

Expand All @@ -332,10 +333,22 @@ impl<'a, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'a, '
context,
table_schema_buf: Default::default(),
args,
with_pk: None,
parent,
}
}

pub fn with_pk(&mut self, table_name: TableName) {
self.with_pk = Some(table_name);
}

pub fn is_scan_with_pk(&self, table_name: &TableName) -> bool {
if let Some(with_pk_table) = self.with_pk.as_ref() {
return with_pk_table == table_name;
}
false
}

pub fn bind(&mut self, stmt: &Statement) -> Result<LogicalPlan, DatabaseError> {
let plan = match stmt {
Statement::Query(query) => self.bind_query(query)?,
Expand Down
Loading
Loading