proof_of_sql/sql/postprocessing/
error.rs

1use alloc::string::String;
2use snafu::Snafu;
3use sqlparser::ast::Ident;
4
5/// Errors in postprocessing
6#[derive(Snafu, Debug, PartialEq, Eq)]
7pub enum PostprocessingError {
8    /// Error in slicing due to slice index beyond usize
9    #[snafu(display("Error in slicing due to slice index beyond usize {index}"))]
10    InvalidSliceIndex {
11        /// The overflowing index value
12        index: i128,
13    },
14    /// Column not found
15    #[snafu(display("Column not found: {column}"))]
16    ColumnNotFound {
17        /// The column which is not found
18        column: String,
19    },
20    /// Index out of bounds
21    #[snafu(display("Index out of bounds: {index}"))]
22    IndexOutOfBounds {
23        /// The index which is out of bounds
24        index: usize,
25    },
26    /// Errors in evaluation of `Expression`s
27    #[snafu(transparent)]
28    ExpressionEvaluationError {
29        /// The underlying source error
30        source: crate::base::database::ExpressionEvaluationError,
31    },
32    /// Errors in constructing `OwnedTable`
33    #[snafu(transparent)]
34    OwnedTableError {
35        /// The underlying source error
36        source: crate::base::database::OwnedTableError,
37    },
38    /// GROUP BY clause references a column not in a group by expression outside aggregate functions
39    #[snafu(display("Invalid group by: column '{column}' must not appear outside aggregate functions or `GROUP BY` clause."))]
40    IdentNotInAggregationOperatorOrGroupByClause {
41        /// The column ident
42        column: Ident,
43    },
44    /// Errors in converting `Ident` to `Identifier`
45    #[snafu(display("Failed to convert `Ident` to `Identifier`: {error}"))]
46    IdentifierConversionError {
47        /// The underlying error message
48        error: String,
49    },
50    /// Errors in aggregate columns
51    #[snafu(transparent)]
52    AggregateColumnsError {
53        /// The underlying source error
54        source: crate::base::database::group_by_util::AggregateColumnsError,
55    },
56    /// Errors in `OwnedColumn`
57    #[snafu(transparent)]
58    OwnedColumnError {
59        /// The underlying source error
60        source: crate::base::database::OwnedColumnError,
61    },
62    /// Nested aggregation in `GROUP BY` clause
63    #[snafu(display("Nested aggregation in `GROUP BY` clause: {error}"))]
64    NestedAggregationInGroupByClause {
65        /// The nested aggregation error
66        error: String,
67    },
68}
69
70/// Result type for postprocessing
71pub type PostprocessingResult<T> = core::result::Result<T, PostprocessingError>;