deltalake_core/data_catalog/
mod.rs

1//! Catalog abstraction for Delta Table
2
3use std::fmt::Debug;
4
5#[cfg(feature = "datafusion")]
6pub mod storage;
7
8/// A result type for data catalog implementations
9pub type DataCatalogResult<T> = Result<T, DataCatalogError>;
10
11/// Error enum that represents a CatalogError.
12#[derive(thiserror::Error, Debug)]
13pub enum DataCatalogError {
14    /// A generic error qualified in the message
15    #[error("Error in {catalog} catalog: {source}")]
16    Generic {
17        /// Name of the catalog
18        catalog: &'static str,
19        /// Error message
20        source: Box<dyn std::error::Error + Send + Sync + 'static>,
21    },
22
23    /// Error representing an invalid Data Catalog.
24    #[error("This data catalog doesn't exist: {data_catalog}")]
25    InvalidDataCatalog {
26        /// The catalog input
27        data_catalog: String,
28    },
29
30    /// Unknown configuration key
31    #[error("Unknown configuration key '{catalog}' in '{key}' catalog.")]
32    UnknownConfigKey {
33        /// Name of the catalog
34        catalog: &'static str,
35
36        /// configuration key
37        key: String,
38    },
39
40    #[error("Error in request: {source}")]
41    RequestError {
42        source: Box<dyn std::error::Error + Send + Sync + 'static>,
43    },
44}
45
46/// Abstractions for data catalog for the Delta table. To add support for new cloud, simply implement this trait.
47#[async_trait::async_trait]
48pub trait DataCatalog: Send + Sync + Debug {
49    type Error;
50
51    /// Get the table storage location from the Data Catalog
52    async fn get_table_storage_location(
53        &self,
54        catalog_id: Option<String>,
55        database_name: &str,
56        table_name: &str,
57    ) -> Result<String, Self::Error>;
58}