Skip to main content

rhei_datafusion/
error.rs

1//! Error types for the DataFusion OLAP backend.
2
3use datafusion::error::DataFusionError;
4
5/// Errors that can occur in the DataFusion OLAP backend.
6///
7/// This enum consolidates errors from DataFusion, Arrow, Parquet, I/O, and
8/// (when the `cloud-storage` feature is enabled) the `object_store` crate.
9#[derive(Debug, thiserror::Error)]
10pub enum DfOlapError {
11    /// An error originating inside the DataFusion query engine.
12    #[error("DataFusion error: {0}")]
13    DataFusion(#[from] DataFusionError),
14
15    /// An Arrow-level error (e.g. schema mismatch during array construction).
16    #[error("Arrow error: {0}")]
17    Arrow(#[from] arrow::error::ArrowError),
18
19    /// A Parquet serialisation or deserialisation error.
20    #[error("Parquet error: {0}")]
21    Parquet(#[from] parquet::errors::ParquetError),
22
23    /// A query or DML statement referenced a table that has not been registered.
24    #[error("table not found: {0}")]
25    TableNotFound(String),
26
27    /// The supplied data schema does not match the registered table schema.
28    #[error("schema mismatch: {0}")]
29    SchemaMismatch(String),
30
31    /// A file-system I/O error (e.g. creating the table directory or writing a file).
32    #[error("I/O error: {0}")]
33    Io(#[from] std::io::Error),
34
35    /// A `tokio::task::JoinError` from a `spawn_blocking` call.
36    #[error("task join error: {0}")]
37    Join(String),
38
39    /// An error from the `object_store` crate (cloud storage operations).
40    ///
41    /// Available on crate feature `cloud-storage` only.
42    #[cfg(feature = "cloud-storage")]
43    #[error("object store error: {0}")]
44    ObjectStore(#[from] object_store::Error),
45
46    /// A URL parse error encountered when constructing cloud storage URLs.
47    ///
48    /// Available on crate feature `cloud-storage` only.
49    #[cfg(feature = "cloud-storage")]
50    #[error("invalid URL: {0}")]
51    UrlParse(#[from] url::ParseError),
52
53    /// A catch-all error for situations not covered by the other variants.
54    #[error("{0}")]
55    Other(String),
56}
57
58impl DfOlapError {
59    /// Wrap a `tokio::task::JoinError` from `spawn_blocking`.
60    pub(crate) fn from_join(e: tokio::task::JoinError) -> Self {
61        Self::Join(e.to_string())
62    }
63}