Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'apache/main' into eper/error-collection
  • Loading branch information
alamb committed Feb 7, 2025
commit e3affd746f9cd46c6bb175e341c2f1ab75e4cd6e
15 changes: 13 additions & 2 deletions datafusion/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,19 @@ pub enum DataFusionError {
/// human-readable messages, and locations in the source query that relate
/// to the error in some way.
Diagnostic(Box<Diagnostic>, Box<DataFusionError>),

/// A collection of one or more [`DataFusionError`]. Useful in cases where
/// DataFusion can recover from an erroneous state, and produce more errors
/// before terminating. e.g. when planning a SELECT clause, DataFusion can
/// synchronize to the next `SelectItem` if the previous one had errors. The
/// end result is that the user can see errors about all `SelectItem`,
/// instead of just the first one.
Collection(Vec<DataFusionError>),
/// A [`DataFusionError`] which shares an underlying [`DataFusionError`].
///
/// This is useful when the same underlying [`DataFusionError`] is passed
/// to multiple receivers. For example, when the source of a repartition
/// errors and the error is propagated to multiple consumers.
Shared(Arc<DataFusionError>),
}

#[macro_export]
Expand Down Expand Up @@ -371,6 +376,7 @@ impl Error for DataFusionError {
// doesn't really change the fact that the query is invalid and
// can't be executed.
DataFusionError::Collection(errs) => errs.first().map(|e| e as &dyn Error),
DataFusionError::Shared(e) => Some(e.as_ref()),
}
}
}
Expand Down Expand Up @@ -494,6 +500,7 @@ impl DataFusionError {
DataFusionError::Collection(errs) => {
errs.first().expect("cannot construct DataFusionError::Collection with 0 errors, but got one such case").error_prefix()
}
DataFusionError::Shared(_) => "",
}
}

Expand Down Expand Up @@ -538,7 +545,11 @@ impl DataFusionError {
// Returning the message of the first error is probably fine enough,
// and makes `DataFusionError::Collection` a transparent wrapped,
// unless the end user explicitly calls `DataFusionError::iter`.
DataFusionError::Collection(ref errs) => errs.first().expect("cannot construct DataFusionError::Collection with 0 errors, but got one such case").message(),
DataFusionError::Collection(ref errs) => errs
.first()
.expect("cannot construct DataFusionError::Collection with 0 errors")
.message(),
DataFusionError::Shared(ref desc) => Cow::Owned(desc.to_string()),
}
}

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.