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
use arrow::datatypes::DataType;
use datafusion::{
common::DataFusionError,
logical_expr::{
expr::{AggregateFunction, Placeholder},
Expr, LogicalPlan, Operator,
},
physical_plan,
};
use proof_of_sql::{base::math::decimal::DecimalError, sql::AnalyzeError};
use snafu::Snafu;
use sqlparser::parser::ParserError;
/// Proof of SQL Planner error
#[derive(Debug, Snafu)]
pub enum PlannerError {
/// Returned when the internal analyze process fails
#[snafu(transparent)]
AnalyzeError {
/// Underlying analyze error
source: AnalyzeError,
},
/// Returned when a decimal error occurs
#[snafu(transparent)]
DecimalError {
/// Underlying decimal error
source: DecimalError,
},
/// Returned when sqlparser fails to parse a query
#[snafu(transparent)]
SqlParserError {
/// Underlying sqlparser error
source: ParserError,
},
/// Returned when datafusion fails to plan a query
#[snafu(transparent)]
DataFusionError {
/// Underlying datafusion error
source: DataFusionError,
},
/// Returned if a column is not found
#[snafu(display("Column not found"))]
ColumnNotFound,
/// Returned if a table is not found
#[snafu(display("Table not found: {}", table_name))]
TableNotFound {
/// Table name
table_name: String,
},
/// Returned when a placeholder id is invalid
#[snafu(display("Placeholder id {id:?} is invalid"))]
InvalidPlaceholderId {
/// Unsupported placeholder id
id: String,
},
/// Returned when a placeholder is untyped
#[snafu(display("Placeholder {placeholder:?} is untyped"))]
UntypedPlaceholder {
/// Untyped placeholder
placeholder: Placeholder,
},
/// Returned when a datatype is not supported
#[snafu(display("Unsupported datatype: {}", data_type))]
UnsupportedDataType {
/// Unsupported datatype
data_type: DataType,
},
/// Returned when a binary operator is not supported
#[snafu(display("Binary operator {} is not supported", op))]
UnsupportedBinaryOperator {
/// Unsupported binary operation
op: Operator,
},
/// Returned when the aggregate opetation is not supported
#[snafu(display("Aggregate operation {op:?} is not supported"))]
UnsupportedAggregateOperation {
/// Unsupported aggregate operation
op: physical_plan::aggregates::AggregateFunction,
},
/// Returned when the `AggregateFunction` is not supported
#[snafu(display("AggregateFunction {function:?} is not supported"))]
UnsupportedAggregateFunction {
/// Unsupported `AggregateFunction`
function: AggregateFunction,
},
/// Returned when a logical expression is not resolved
#[snafu(display("Logical expression {:?} is not supported", expr))]
UnsupportedLogicalExpression {
/// Unsupported logical expression
expr: Box<Expr>,
},
/// Returned when a `LogicalPlan` is not supported
#[snafu(display("LogicalPlan is not supported"))]
UnsupportedLogicalPlan {
/// Unsupported `LogicalPlan`
plan: Box<LogicalPlan>,
},
/// Returned when the `LogicalPlan` is not resolved
#[snafu(display("LogicalPlan is not resolved"))]
UnresolvedLogicalPlan,
/// Returned when catalog is provided since it is not supported
#[snafu(display("Catalog is not supported"))]
CatalogNotSupported,
}
/// Proof of SQL Planner result
pub type PlannerResult<T> = Result<T, PlannerError>;