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
use std::fmt;
/// Errors that can occur during WPL-to-Arrow type conversion.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum WpArrowError {
/// The given type name is not a recognized WPL data type.
UnsupportedDataType(String),
/// An `array<...>` type has an invalid or missing inner type.
InvalidArrayInnerType(String),
/// A field definition has an empty name.
EmptyFieldName,
/// A required (non-nullable) field is missing from the record.
MissingRequiredField { field_name: String },
/// Wrapper for `arrow::error::ArrowError` (stored as String because ArrowError is not Clone/Eq).
ArrowBuildError(String),
/// A field value does not match the expected WpDataType.
ValueConversionError {
field_name: String,
expected: String,
actual: String,
},
/// The number of FieldDefs does not match the number of columns in the RecordBatch.
SchemaMismatch { expected: usize, actual: usize },
/// A NaiveDateTime value overflows the i64 nanosecond representation.
TimestampOverflow { field_name: String },
/// Failed to parse a string value back into the expected type.
ParseError { field_name: String, detail: String },
/// IPC encoding failed (wraps Arrow IPC writer errors).
IpcEncodeError(String),
/// IPC decoding failed (malformed frame, incomplete data, etc.).
IpcDecodeError(String),
}
impl fmt::Display for WpArrowError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
WpArrowError::UnsupportedDataType(t) => {
write!(f, "unsupported WPL data type: {t}")
}
WpArrowError::InvalidArrayInnerType(t) => {
write!(f, "invalid array inner type: {t}")
}
WpArrowError::EmptyFieldName => {
write!(f, "field name must not be empty")
}
WpArrowError::MissingRequiredField { field_name } => {
write!(f, "missing required field: {field_name}")
}
WpArrowError::ArrowBuildError(msg) => {
write!(f, "arrow build error: {msg}")
}
WpArrowError::ValueConversionError {
field_name,
expected,
actual,
} => {
write!(
f,
"value conversion error for field '{field_name}': expected {expected}, got {actual}"
)
}
WpArrowError::SchemaMismatch { expected, actual } => {
write!(
f,
"schema mismatch: expected {expected} columns, got {actual}"
)
}
WpArrowError::TimestampOverflow { field_name } => {
write!(
f,
"timestamp overflow for field '{field_name}': value out of i64 nanosecond range"
)
}
WpArrowError::ParseError { field_name, detail } => {
write!(f, "parse error for field '{field_name}': {detail}")
}
WpArrowError::IpcEncodeError(msg) => {
write!(f, "IPC encode error: {msg}")
}
WpArrowError::IpcDecodeError(msg) => {
write!(f, "IPC decode error: {msg}")
}
}
}
}
impl std::error::Error for WpArrowError {}