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    /// Errors in evaluation of `Expression`s
21    #[snafu(transparent)]
22    ExpressionEvaluationError {
23        /// The underlying source error
24        source: crate::base::database::ExpressionEvaluationError,
25    },
26    /// Errors in constructing `OwnedTable`
27    #[snafu(transparent)]
28    OwnedTableError {
29        /// The underlying source error
30        source: crate::base::database::OwnedTableError,
31    },
32    /// GROUP BY clause references a column not in a group by expression outside aggregate functions
33    #[snafu(display("Invalid group by: column '{column}' must not appear outside aggregate functions or `GROUP BY` clause."))]
34    IdentNotInAggregationOperatorOrGroupByClause {
35        /// The column ident
36        column: Ident,
37    },
38    /// Errors in converting `Ident` to `Identifier`
39    #[snafu(display("Failed to convert `Ident` to `Identifier`: {error}"))]
40    IdentifierConversionError {
41        /// The underlying error message
42        error: String,
43    },
44    /// Errors in aggregate columns
45    #[snafu(transparent)]
46    AggregateColumnsError {
47        /// The underlying source error
48        source: crate::base::database::group_by_util::AggregateColumnsError,
49    },
50    /// Errors in `OwnedColumn`
51    #[snafu(transparent)]
52    OwnedColumnError {
53        /// The underlying source error
54        source: crate::base::database::OwnedColumnError,
55    },
56    /// Nested aggregation in `GROUP BY` clause
57    #[snafu(display("Nested aggregation in `GROUP BY` clause: {error}"))]
58    NestedAggregationInGroupByClause {
59        /// The nested aggregation error
60        error: String,
61    },
62}
63
64/// Result type for postprocessing
65pub type PostprocessingResult<T> = core::result::Result<T, PostprocessingError>;