Skip to content

Commit 7d377dc

Browse files
author
Cheng-Yuan-Lai
committed
feat: removing optional backtrace parameter
1 parent 6a893eb commit 7d377dc

File tree

1 file changed

+19
-38
lines changed

1 file changed

+19
-38
lines changed

datafusion/common/src/error.rs

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ pub enum DataFusionError {
129129
/// Errors originating from outside DataFusion's core codebase.
130130
///
131131
/// For example, a custom S3Error from the crate datafusion-objectstore-s3
132-
///
133-
/// 2nd argument is for optional backtrace
134-
External(GenericError, Option<String>),
132+
External(GenericError),
135133
/// Error with additional context
136134
Context(String, Box<DataFusionError>),
137135
/// Errors from either mapping LogicalPlans to/from Substrait plans
@@ -294,7 +292,7 @@ impl From<DataFusionError> for ArrowError {
294292
fn from(e: DataFusionError) -> Self {
295293
match e {
296294
DataFusionError::ArrowError(e, _) => e,
297-
DataFusionError::External(e, _) => ArrowError::ExternalError(e),
295+
DataFusionError::External(e) => ArrowError::ExternalError(e),
298296
other => ArrowError::ExternalError(Box::new(other)),
299297
}
300298
}
@@ -355,7 +353,7 @@ impl From<GenericError> for DataFusionError {
355353
unreachable!()
356354
}
357355
} else {
358-
DataFusionError::External(err, None)
356+
DataFusionError::External(err)
359357
}
360358
}
361359
}
@@ -388,7 +386,7 @@ impl Error for DataFusionError {
388386
DataFusionError::Execution(_) => None,
389387
DataFusionError::ExecutionJoin(e, _) => Some(e),
390388
DataFusionError::ResourcesExhausted(_) => None,
391-
DataFusionError::External(e, _) => Some(e.as_ref()),
389+
DataFusionError::External(e) => Some(e.as_ref()),
392390
DataFusionError::Context(_, e) => Some(e.as_ref()),
393391
DataFusionError::Substrait(_) => None,
394392
DataFusionError::Diagnostic(_, e) => Some(e.as_ref()),
@@ -522,7 +520,7 @@ impl DataFusionError {
522520
DataFusionError::ResourcesExhausted(_) => {
523521
"Resources exhausted: "
524522
}
525-
DataFusionError::External(_, _) => "External error: ",
523+
DataFusionError::External(_) => "External error: ",
526524
DataFusionError::Context(_, _) => "",
527525
DataFusionError::Substrait(_) => "Substrait error: ",
528526
DataFusionError::Diagnostic(_, _) => "",
@@ -567,10 +565,7 @@ impl DataFusionError {
567565
Cow::Owned(format!("{desc}{backtrace}"))
568566
}
569567
DataFusionError::ResourcesExhausted(ref desc) => Cow::Owned(desc.to_string()),
570-
DataFusionError::External(ref desc, ref backtrace) => {
571-
let backtrace = backtrace.clone().unwrap_or_else(|| "".to_owned());
572-
Cow::Owned(format!("{desc}{backtrace}"))
573-
}
568+
DataFusionError::External(ref desc) => Cow::Owned(desc.to_string()),
574569
#[cfg(feature = "object_store")]
575570
DataFusionError::ObjectStore(ref desc) => Cow::Owned(desc.to_string()),
576571
DataFusionError::Context(ref desc, ref err) => {
@@ -923,11 +918,7 @@ macro_rules! schema_err {
923918
#[macro_export]
924919
macro_rules! external_datafusion_err {
925920
($CONVERTIBLE_TO_ERR:expr $(; diagnostic = $DIAG:expr)?) => {{
926-
let err = $crate::error::DataFusionError::External(
927-
// covert input to GenericError
928-
$crate::error::GenericError::from($CONVERTIBLE_TO_ERR),
929-
Some($crate::error::DataFusionError::get_back_trace())
930-
);
921+
let err = $crate::error::DataFusionError::External($crate::error::GenericError::from($CONVERTIBLE_TO_ERR)).context($crate::error::DataFusionError::get_back_trace());
931922
$(
932923
let err = err.with_diagnostic($DIAG);
933924
)?
@@ -1099,20 +1090,16 @@ mod test {
10991090
);
11001091

11011092
do_root_test(
1102-
DataFusionError::External(
1103-
Box::new(DataFusionError::ResourcesExhausted("foo".to_string())),
1104-
None,
1105-
),
1093+
DataFusionError::External(Box::new(DataFusionError::ResourcesExhausted(
1094+
"foo".to_string(),
1095+
))),
11061096
DataFusionError::ResourcesExhausted("foo".to_string()),
11071097
);
11081098

11091099
do_root_test(
1110-
DataFusionError::External(
1111-
Box::new(ArrowError::ExternalError(Box::new(
1112-
DataFusionError::ResourcesExhausted("foo".to_string()),
1113-
))),
1114-
None,
1115-
),
1100+
DataFusionError::External(Box::new(ArrowError::ExternalError(Box::new(
1101+
DataFusionError::ResourcesExhausted("foo".to_string()),
1102+
)))),
11161103
DataFusionError::ResourcesExhausted("foo".to_string()),
11171104
);
11181105

@@ -1127,22 +1114,16 @@ mod test {
11271114
);
11281115

11291116
do_root_test(
1130-
DataFusionError::External(
1131-
Box::new(Arc::new(DataFusionError::ResourcesExhausted(
1132-
"foo".to_string(),
1133-
))),
1134-
None,
1135-
),
1117+
DataFusionError::External(Box::new(Arc::new(
1118+
DataFusionError::ResourcesExhausted("foo".to_string()),
1119+
))),
11361120
DataFusionError::ResourcesExhausted("foo".to_string()),
11371121
);
11381122

11391123
do_root_test(
1140-
DataFusionError::External(
1141-
Box::new(Arc::new(ArrowError::ExternalError(Box::new(
1142-
DataFusionError::ResourcesExhausted("foo".to_string()),
1143-
)))),
1144-
None,
1145-
),
1124+
DataFusionError::External(Box::new(Arc::new(ArrowError::ExternalError(
1125+
Box::new(DataFusionError::ResourcesExhausted("foo".to_string())),
1126+
)))),
11461127
DataFusionError::ResourcesExhausted("foo".to_string()),
11471128
);
11481129
}

0 commit comments

Comments
 (0)