Skip to content

Commit

Permalink
code fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Feb 6, 2024
1 parent 44d8035 commit 1a25c92
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/binder/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a, T: Transaction> Binder<'a, T> {
let value = DataValue::Utf8(Some(value.to_string())).cast(&logical_type)?;

Ok(ScalarExpression::Constant(Arc::new(value)))
},
}
_ => {
todo!()
}
Expand Down Expand Up @@ -220,7 +220,7 @@ impl<'a, T: Transaction> Binder<'a, T> {
args,
ty,
}
},
}
"min" => {
let ty = args[0].return_type();

Expand All @@ -230,7 +230,7 @@ impl<'a, T: Transaction> Binder<'a, T> {
args,
ty,
}
},
}
"max" => {
let ty = args[0].return_type();

Expand All @@ -240,7 +240,7 @@ impl<'a, T: Transaction> Binder<'a, T> {
args,
ty,
}
},
}
"avg" => {
let ty = args[0].return_type();

Expand All @@ -250,7 +250,7 @@ impl<'a, T: Transaction> Binder<'a, T> {
args,
ty,
}
},
}
_ => todo!(),
})
}
Expand Down
14 changes: 11 additions & 3 deletions src/binder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,27 @@ impl<'a, T: Transaction> BinderContext<'a, T> {
}
}

pub fn table_and_bind(&mut self, table_name: TableName, join_type: Option<JoinType>) -> Result<&TableCatalog, DatabaseError> {
pub fn table_and_bind(
&mut self,
table_name: TableName,
join_type: Option<JoinType>,
) -> Result<&TableCatalog, DatabaseError> {
let table = if let Some(real_name) = self.table_aliases.get(table_name.as_ref()) {
self.transaction.table(real_name.clone())
} else {
self.transaction.table(table_name.clone())
}.ok_or(DatabaseError::TableNotFound)?;
}
.ok_or(DatabaseError::TableNotFound)?;

let is_bound = self
.bind_table
.insert(table_name.clone(), (table, join_type))
.is_some();
if is_bound {
return Err(DatabaseError::InvalidTable(format!("{} duplicated", table_name)));
return Err(DatabaseError::InvalidTable(format!(
"{} duplicated",
table_name
)));
}

Ok(table)
Expand Down
2 changes: 1 addition & 1 deletion src/execution/volcano/dql/dummy.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::sync::Arc;
use crate::errors::DatabaseError;
use crate::execution::volcano::{BoxedExecutor, ReadExecutor};
use crate::storage::Transaction;
use crate::types::tuple::Tuple;
use futures_async_stream::try_stream;
use std::sync::Arc;

pub struct Dummy {}

Expand Down
14 changes: 8 additions & 6 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,15 @@ impl TryFrom<sqlparser::ast::DataType> for LogicalType {
sqlparser::ast::DataType::Boolean => Ok(LogicalType::Boolean),
sqlparser::ast::DataType::Date => Ok(LogicalType::Date),
sqlparser::ast::DataType::Datetime(_) => Ok(LogicalType::DateTime),
sqlparser::ast::DataType::Decimal(info) | sqlparser::ast::DataType::Dec(info) => match info {
ExactNumberInfo::None => Ok(Self::Decimal(None, None)),
ExactNumberInfo::Precision(p) => Ok(Self::Decimal(Some(p as u8), None)),
ExactNumberInfo::PrecisionAndScale(p, s) => {
Ok(Self::Decimal(Some(p as u8), Some(s as u8)))
sqlparser::ast::DataType::Decimal(info) | sqlparser::ast::DataType::Dec(info) => {
match info {
ExactNumberInfo::None => Ok(Self::Decimal(None, None)),
ExactNumberInfo::Precision(p) => Ok(Self::Decimal(Some(p as u8), None)),
ExactNumberInfo::PrecisionAndScale(p, s) => {
Ok(Self::Decimal(Some(p as u8), Some(s as u8)))
}
}
},
}
other => Err(DatabaseError::NotImplementedSqlparserDataType(
other.to_string(),
)),
Expand Down

0 comments on commit 1a25c92

Please sign in to comment.