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
use std::fmt;
/// Why a table or view operation was refused. Nothing changes when one is returned.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum DataError {
/// No column has this name.
UnknownColumn(String),
/// The key column must hold integers or strings.
UnsupportedKey(String),
/// Views and groups cannot read this column's data type (lists, structs, binary, ...).
UnsupportedColumn(String),
/// A filter's value or operation does not fit this column's type (text compared with a
/// number, `contains` on a number).
LiteralMismatch(String),
/// Sums and means need an integer, decimal or float column; this one holds something
/// else (text, booleans, dates, times).
NotNumeric(String),
/// A window's span does not fit its column: a `Duration` goes with dates, times and
/// timestamps, a number (zero or more) with integers, decimals and floats.
WindowSpan(String),
/// Two columns of a group spec's result would have this name.
DuplicateName(String),
/// The batch has a different number of columns.
ColumnCount {
/// Columns in the table.
expected: usize,
/// Columns in the batch.
found: usize,
},
/// The batch's column at this index has another name or data type.
ColumnMismatch {
/// Index of the first differing column.
column: usize,
},
/// A row of the batch has no key.
NullKey {
/// The row, within the batch.
row: usize,
},
/// Keys to delete or find are not of the key column's kind (text for a number key).
KeyType,
/// More than 2^32 live keys, or rows in one batch.
TooManyRows,
/// Arrow could not build a batch: compacting a table, or assembling groups.
Arrow(String),
}
impl fmt::Display for DataError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::UnknownColumn(name) => write!(f, "there is no column named {name:?}"),
Self::UnsupportedKey(name) => {
write!(f, "key column {name:?} must hold integers or strings")
}
Self::UnsupportedColumn(name) => {
write!(
f,
"views and groups cannot read column {name:?} of this type"
)
}
Self::LiteralMismatch(name) => {
write!(f, "the filter does not fit the type of column {name:?}")
}
Self::NotNumeric(name) => {
write!(f, "column {name:?} is not numeric: it cannot be summed")
}
Self::WindowSpan(name) => {
write!(
f,
"the window's span does not fit the type of column {name:?}"
)
}
Self::DuplicateName(name) => write!(f, "two result columns are named {name:?}"),
Self::ColumnCount { expected, found } => {
write!(f, "the batch has {found} columns, the table {expected}")
}
Self::ColumnMismatch { column } => {
write!(
f,
"column {column} of the batch has another name or data type"
)
}
Self::NullKey { row } => write!(f, "row {row} of the batch has a null key"),
Self::KeyType => f.write_str("the keys are not of the key column's kind"),
Self::TooManyRows => f.write_str("more than 2^32 live keys, or rows in one batch"),
Self::Arrow(message) => write!(f, "Arrow could not build a batch: {message}"),
}
}
}
impl std::error::Error for DataError {}
impl DataError {
pub(crate) fn arrow(error: arrow_schema::ArrowError) -> Self {
Self::Arrow(error.to_string())
}
}