proof_of_sql/sql/postprocessing/
error.rs

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
use alloc::string::String;
use proof_of_sql_parser::Identifier;
use snafu::Snafu;

/// Errors in postprocessing
#[derive(Snafu, Debug, PartialEq, Eq)]
pub enum PostprocessingError {
    /// Error in slicing due to slice index beyond usize
    #[snafu(display("Error in slicing due to slice index beyond usize {index}"))]
    InvalidSliceIndex {
        /// The overflowing index value
        index: i128,
    },
    /// Column not found
    #[snafu(display("Column not found: {column}"))]
    ColumnNotFound {
        /// The column which is not found
        column: String,
    },
    /// Errors in evaluation of `Expression`s
    #[snafu(transparent)]
    ExpressionEvaluationError {
        /// The underlying source error
        source: crate::base::database::ExpressionEvaluationError,
    },
    /// Errors in constructing `OwnedTable`
    #[snafu(transparent)]
    OwnedTableError {
        /// The underlying source error
        source: crate::base::database::OwnedTableError,
    },
    /// GROUP BY clause references a column not in a group by expression outside aggregate functions
    #[snafu(display("Invalid group by: column '{column}' must not appear outside aggregate functions or `GROUP BY` clause."))]
    IdentifierNotInAggregationOperatorOrGroupByClause {
        /// The column identifier
        column: Identifier,
    },
    /// Errors in aggregate columns
    #[snafu(transparent)]
    AggregateColumnsError {
        /// The underlying source error
        source: crate::base::database::group_by_util::AggregateColumnsError,
    },
    /// Errors in `OwnedColumn`
    #[snafu(transparent)]
    OwnedColumnError {
        /// The underlying source error
        source: crate::base::database::OwnedColumnError,
    },
    /// Nested aggregation in `GROUP BY` clause
    #[snafu(display("Nested aggregation in `GROUP BY` clause: {error}"))]
    NestedAggregationInGroupByClause {
        /// The nested aggregation error
        error: String,
    },
}

/// Result type for postprocessing
pub type PostprocessingResult<T> = core::result::Result<T, PostprocessingError>;