use nodedb_types::DatabaseId;
use thiserror::Error;
use crate::types::CollectionInfo;
use crate::types_array::{ArrayAttrAst, ArrayDimAst};
#[derive(Debug, Clone, Error)]
pub enum SqlCatalogError {
#[error("retryable schema change on {descriptor}")]
RetryableSchemaChanged {
descriptor: String,
},
#[error(
"collection '{name}' was dropped and is within its retention window; \
restore with UNDROP COLLECTION before {retention_expires_at_ns} ns"
)]
CollectionDeactivated {
name: String,
retention_expires_at_ns: u64,
},
}
pub trait SqlCatalog {
fn get_collection(
&self,
database_id: DatabaseId,
name: &str,
) -> Result<Option<CollectionInfo>, SqlCatalogError>;
fn lookup_array(&self, _name: &str) -> Option<ArrayCatalogView> {
None
}
fn array_exists(&self, name: &str) -> bool {
self.lookup_array(name).is_some()
}
}
#[derive(Debug, Clone)]
pub struct ArrayCatalogView {
pub name: String,
pub dims: Vec<ArrayDimAst>,
pub attrs: Vec<ArrayAttrAst>,
pub tile_extents: Vec<i64>,
}