rhei-duckdb 2.0.0

DuckDB OLAP backend for Rhei HTAP engine
Documentation
//! Error types for the DuckDB OLAP backend.
//!
//! [`DuckDbError`] is the single error type returned by all fallible operations
//! in this crate. It consolidates errors from the DuckDB C++ library, Arrow
//! record-batch construction, core schema validation, and Tokio's
//! `spawn_blocking` task machinery.

use thiserror::Error;

/// Unified error type for [`crate::DuckDbEngine`] operations.
///
/// Implements [`std::error::Error`] via [`thiserror`] and can be converted from
/// several underlying error types using `?`.
#[derive(Debug, Error)]
pub enum DuckDbError {
    /// A native DuckDB error returned by the C++ engine (query execution,
    /// connection, Appender flush, etc.).
    #[error("DuckDB error: {0}")]
    DuckDb(#[from] duckdb::Error),

    /// An Arrow record-batch construction or schema mismatch error.
    #[error("arrow error: {0}")]
    Arrow(#[from] arrow::error::ArrowError),

    /// A schema validation error from [`rhei_core`] (e.g. invalid identifier
    /// containing characters outside `[A-Za-z0-9_]`).
    #[error("schema error: {0}")]
    Schema(#[from] rhei_core::CoreError),

    /// A `tokio::task::spawn_blocking` task panicked or was cancelled.
    /// The inner string is the stringified [`tokio::task::JoinError`].
    #[error("spawn_blocking join error: {0}")]
    Join(String),

    /// A catch-all error for situations not covered by the variants above.
    #[error("{0}")]
    Other(String),
}

impl DuckDbError {
    /// Wrap a `tokio::task::JoinError` from `spawn_blocking`.
    pub(crate) fn from_join(e: tokio::task::JoinError) -> Self {
        Self::Join(e.to_string())
    }
}