| 373 | |
| 374 | impl Error for DataFusionError { |
| 375 | fn source(&self) -> Option<&(dyn Error + 'static)> { |
| 376 | match self { |
| 377 | DataFusionError::ArrowError(e, _) => Some(e.as_ref()), |
| 378 | #[cfg(feature = "parquet")] |
| 379 | DataFusionError::ParquetError(e) => Some(e.as_ref()), |
| 380 | #[cfg(feature = "object_store")] |
| 381 | DataFusionError::ObjectStore(e) => Some(e.as_ref()), |
| 382 | DataFusionError::IoError(e) => Some(e), |
| 383 | #[cfg(feature = "sql")] |
| 384 | DataFusionError::SQL(e, _) => Some(e.as_ref()), |
| 385 | DataFusionError::NotImplemented(_) => None, |
| 386 | DataFusionError::Internal(_) => None, |
| 387 | DataFusionError::Configuration(_) => None, |
| 388 | DataFusionError::Plan(_) => None, |
| 389 | DataFusionError::SchemaError(e, _) => Some(e.as_ref()), |
| 390 | DataFusionError::Execution(_) => None, |
| 391 | DataFusionError::ExecutionJoin(e) => Some(e.as_ref()), |
| 392 | DataFusionError::ResourcesExhausted(_) => None, |
| 393 | DataFusionError::External(e) => Some(e.as_ref()), |
| 394 | DataFusionError::Context(_, e) => Some(e.as_ref()), |
| 395 | DataFusionError::Substrait(_) => None, |
| 396 | DataFusionError::Diagnostic(_, e) => Some(e.as_ref()), |
| 397 | // Can't really make a Collection fit into the mold of "an error has |
| 398 | // at most one source", but returning the first one is probably good |
| 399 | // idea. Especially since `DataFusionError::Collection` is mostly |
| 400 | // meant for consumption by the end user, so shouldn't interfere |
| 401 | // with programmatic usage too much. Plus, having 1 or 5 errors |
| 402 | // doesn't really change the fact that the query is invalid and |
| 403 | // can't be executed. |
| 404 | DataFusionError::Collection(errs) => errs.first().map(|e| e as &dyn Error), |
| 405 | DataFusionError::Shared(e) => Some(e.as_ref()), |
| 406 | DataFusionError::Ffi(_) => None, |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | impl From<DataFusionError> for io::Error { |