Skip to content

Commit

Permalink
Add errors from BaseTableExpr's to the evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr committed Mar 7, 2024
1 parent 4d9ae54 commit 265a442
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions partiql-catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct ObjectId {
}

pub type BaseTableExprResultError = Box<dyn Error>;

pub type BaseTableExprResultValueIter<'a> =
Box<dyn 'a + Iterator<Item = Result<Value, BaseTableExprResultError>>>;
pub type BaseTableExprResult<'a> =
Expand Down
13 changes: 12 additions & 1 deletion partiql-eval/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::eval::evaluable::Evaluable;
use crate::eval::expr::EvalExpr;
use crate::eval::EvalContext;
use partiql_catalog::BaseTableExprResultError;
use partiql_value::{Tuple, Value};
use std::borrow::Cow;
use thiserror::Error;
Expand Down Expand Up @@ -30,7 +31,7 @@ pub struct EvalErr {
}

/// An error that can happen during evaluation.
#[derive(Error, Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum EvaluationError {
/// Internal error that was not due to user input or API violation.
Expand All @@ -42,6 +43,16 @@ pub enum EvaluationError {
/// Feature has not yet been implemented.
#[error("Not yet implemented: {0}")]
NotYetImplemented(String),

/// Error originating in an extension
#[error("Base Table Expression Error: {0}")]
ExtensionBaseTableExprResultError(BaseTableExprResultError),
}

impl From<BaseTableExprResultError> for EvaluationError {
fn from(e: BaseTableExprResultError) -> Self {
EvaluationError::ExtensionBaseTableExprResultError(e)
}
}

/// Used when an error occurs during the the logical to eval plan conversion. Allows the conversion
Expand Down
8 changes: 4 additions & 4 deletions partiql-eval/src/eval/expr/base_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ impl EvalExpr for EvalFnBaseTableExpr {
let bag: Result<Bag, _> = it.collect();
match bag {
Ok(b) => Value::from(b),
Err(_) => {
// TODO hook into pending eval errors
Err(err) => {
ctx.add_error(err.into());
Missing
}
}
}
Err(_) => {
// TODO hook into pending eval errors
Err(err) => {
ctx.add_error(err.into());
Missing
}
};
Expand Down

0 comments on commit 265a442

Please sign in to comment.