Skip to content

Commit

Permalink
refine todo behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Oct 17, 2023
1 parent 0de5792 commit 95084fd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/expr/core/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,22 @@ impl<E> NonStrictExpression<E>
where
E: Expression,
{
/// Create a non-strict expression directly wrapping the given expression.
///
/// Should only be used in tests as evaluation may panic.
pub fn for_test(inner: E) -> NonStrictExpression
where
E: 'static,
{
NonStrictExpression(inner.boxed())
}

pub fn todo(inner: E) -> Self {
Self(inner)
/// Create a non-strict expression from the given expression, where only the evaluation of the
/// top-level expression is non-strict (which is subtly different from
/// [`crate::expr::build_non_strict_from_prost`]), and error will only be simply logged.
pub fn todo(inner: E) -> NonStrictExpression<impl Expression> {
let inner = wrapper::non_strict::NonStrict::new(inner, wrapper::LogReport);
NonStrictExpression(inner)
}

/// Get the return data type.
Expand Down
2 changes: 1 addition & 1 deletion src/expr/core/src/expr/wrapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
pub(crate) mod checked;
pub(crate) mod non_strict;

pub use non_strict::EvalErrorReport;
pub use non_strict::{EvalErrorReport, LogReport};
10 changes: 10 additions & 0 deletions src/expr/core/src/expr/wrapper/non_strict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ impl EvalErrorReport for ! {
}
}

/// Log the error to report an error during evaluation.
#[derive(Clone)]
pub struct LogReport;

impl EvalErrorReport for LogReport {
fn report(&self, error: ExprError) {
tracing::error!(%error, "failed to evaluate expression");
}
}

/// A wrapper of [`Expression`] that evaluates in a non-strict way. Basically...
/// - When an error occurs during chunk-level evaluation, recompute in row-based execution and pad
/// with NULL for each failed row.
Expand Down

0 comments on commit 95084fd

Please sign in to comment.