Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add errors from BaseTableExpr's to the evaluator #447

Merged
merged 7 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Adds quotes to the attributes of PartiQL tuple's debug output so it can be read and transformed using Kotlin `partiql-cli`
- [breaking] Changes the interface to `EvalPlan` to accept an `EvalContext`
- [breaking] Changes `EvaluationError` to not implement `Clone`

### Added
- Add `partiql-extension-visualize` for visualizing AST and logical plan
- Add a `SessionContext` containing both a system-level and a user-level context object usable by expression evaluation

### Fixed
- Fixed `ORDER BY`'s ability to see into projection aliases
- Fixed errors in `BaseTableExpr`s get added to the evaluation context

## [0.6.0] - 2023-10-31
### Changed
Expand Down
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),
jpschorr marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading