proof_of_sql/base/database/
column_operation_error.rsuse crate::base::{database::ColumnType, math::decimal::DecimalError};
use alloc::string::String;
use core::result::Result;
use proof_of_sql_parser::intermediate_ast::{BinaryOperator, UnaryOperator};
use snafu::Snafu;
#[derive(Snafu, Debug, PartialEq, Eq)]
pub enum ColumnOperationError {
#[snafu(display("Columns have different lengths: {len_a} != {len_b}"))]
DifferentColumnLength {
len_a: usize,
len_b: usize,
},
#[snafu(display("{operator:?}(lhs: {left_type:?}, rhs: {right_type:?}) is not supported"))]
BinaryOperationInvalidColumnType {
operator: BinaryOperator,
left_type: ColumnType,
right_type: ColumnType,
},
#[snafu(display("{operator:?}(operand: {operand_type:?}) is not supported"))]
UnaryOperationInvalidColumnType {
operator: UnaryOperator,
operand_type: ColumnType,
},
#[snafu(display("Overflow in integer operation: {error}"))]
IntegerOverflow {
error: String,
},
#[snafu(display("Division by zero"))]
DivisionByZero,
#[snafu(transparent)]
DecimalConversionError {
source: DecimalError,
},
}
pub type ColumnOperationResult<T> = Result<T, ColumnOperationError>;