Skip to content

Commit

Permalink
refactor!: remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
iajoiner committed Nov 12, 2024
1 parent ffdcf8f commit 0dad376
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 307 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ use crate::base::{
math::decimal::Precision,
scalar::Scalar,
};
use alloc::vec::Vec;
use alloc::{string::ToString, vec::Vec};
use core::fmt::Debug;
use num_bigint::BigInt;
use num_traits::{CheckedAdd, CheckedDiv, CheckedMul, CheckedSub};
use proof_of_sql_parser::intermediate_ast::BinaryOperator;

pub trait ArithmeticOp {
fn op<T>(l: &T, r: &T) -> ColumnOperationResult<T>
Expand Down Expand Up @@ -186,7 +185,7 @@ pub trait ArithmeticOp {
Ok(OwnedColumn::Decimal75(new_precision, new_scale, new_values))
}
_ => Err(ColumnOperationError::BinaryOperationInvalidColumnType {
operator: BinaryOperator::Add,
operator: "ArithmeticOp".to_string(),
left_type: lhs.column_type(),
right_type: rhs.column_type(),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ use crate::base::{
},
scalar::Scalar,
};
use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::{cmp::Ord, fmt::Debug};
use num_traits::Zero;
use proof_of_sql_parser::intermediate_ast::BinaryOperator;

pub trait ComparisonOp {
fn op<T>(l: &T, r: &T) -> bool
Expand Down Expand Up @@ -223,9 +226,12 @@ pub trait ComparisonOp {
rhs.column_type(),
)),

(OwnedColumn::Boolean(lhs), OwnedColumn::Boolean(rhs)) => {
Ok(slice_binary_op(lhs, rhs, Self::op))
}
(OwnedColumn::VarChar(lhs), OwnedColumn::VarChar(rhs)) => Self::string_op(lhs, rhs),
_ => Err(ColumnOperationError::BinaryOperationInvalidColumnType {
operator: BinaryOperator::Add,
operator: "ComparisonOp".to_string(),
left_type: lhs.column_type(),
right_type: rhs.column_type(),
}),
Expand Down Expand Up @@ -311,7 +317,7 @@ impl ComparisonOp for GreaterThanOrEqualOp {

fn string_op(_lhs: &[String], _rhs: &[String]) -> ColumnOperationResult<Vec<bool>> {
Err(ColumnOperationError::BinaryOperationInvalidColumnType {
operator: BinaryOperator::Add,
operator: ">=".to_string(),
left_type: ColumnType::VarChar,
right_type: ColumnType::VarChar,
})
Expand Down Expand Up @@ -355,7 +361,7 @@ impl ComparisonOp for LessThanOrEqualOp {

fn string_op(_lhs: &[String], _rhs: &[String]) -> ColumnOperationResult<Vec<bool>> {
Err(ColumnOperationError::BinaryOperationInvalidColumnType {
operator: BinaryOperator::Add,
operator: "<=".to_string(),
left_type: ColumnType::VarChar,
right_type: ColumnType::VarChar,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ impl<S: Scalar> OwnedTable<S> {
BinaryOperator::Equal => Ok(left.element_wise_eq(&right)?),
BinaryOperator::GreaterThanOrEqual => Ok(left.element_wise_ge(&right)?),
BinaryOperator::LessThanOrEqual => Ok(left.element_wise_le(&right)?),
BinaryOperator::Add => Ok((left + right)?),
BinaryOperator::Subtract => Ok((left - right)?),
BinaryOperator::Multiply => Ok((left * right)?),
BinaryOperator::Division => Ok((left / right)?),
BinaryOperator::Add => Ok(left.element_wise_add(&right)?),
BinaryOperator::Subtract => Ok(left.element_wise_sub(&right)?),
BinaryOperator::Multiply => Ok(left.element_wise_mul(&right)?),
BinaryOperator::Division => Ok(left.element_wise_div(&right)?),
}
}
}
Loading

0 comments on commit 0dad376

Please sign in to comment.