1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use std::error;
use std::fmt::{Display, Formatter};
use std::io;
use std::result;
use arrow::error::ArrowError;
use parquet::errors::ParquetError;
use sqlparser::parser::ParserError;
pub type Result<T> = result::Result<T, DataFusionError>;
#[derive(Debug)]
#[allow(missing_docs)]
pub enum DataFusionError {
ArrowError(ArrowError),
ParquetError(ParquetError),
IoError(io::Error),
SQL(ParserError),
NotImplemented(String),
Internal(String),
Plan(String),
Execution(String),
}
impl DataFusionError {
pub fn into_arrow_external_error(self) -> ArrowError {
ArrowError::from_external_error(Box::new(self))
}
}
impl From<io::Error> for DataFusionError {
fn from(e: io::Error) -> Self {
DataFusionError::IoError(e)
}
}
impl From<ArrowError> for DataFusionError {
fn from(e: ArrowError) -> Self {
DataFusionError::ArrowError(e)
}
}
impl From<ParquetError> for DataFusionError {
fn from(e: ParquetError) -> Self {
DataFusionError::ParquetError(e)
}
}
impl From<ParserError> for DataFusionError {
fn from(e: ParserError) -> Self {
DataFusionError::SQL(e)
}
}
impl Display for DataFusionError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match *self {
DataFusionError::ArrowError(ref desc) => write!(f, "Arrow error: {}", desc),
DataFusionError::ParquetError(ref desc) => {
write!(f, "Parquet error: {}", desc)
}
DataFusionError::IoError(ref desc) => write!(f, "IO error: {}", desc),
DataFusionError::SQL(ref desc) => {
write!(f, "SQL error: {:?}", desc)
}
DataFusionError::NotImplemented(ref desc) => {
write!(f, "This feature is not implemented: {}", desc)
}
DataFusionError::Internal(ref desc) => {
write!(f, "Internal error: {}. This was likely caused by a bug in DataFusion's \
code and we would welcome that you file an bug report in our issue tracker", desc)
}
DataFusionError::Plan(ref desc) => {
write!(f, "Error during planning: {}", desc)
}
DataFusionError::Execution(ref desc) => {
write!(f, "Execution error: {}", desc)
}
}
}
}
impl error::Error for DataFusionError {}