From b22c40bb4200a96bada3fce4d5ce2f02a4d472fa Mon Sep 17 00:00:00 2001 From: Marko Grujic Date: Wed, 28 Feb 2024 11:23:16 +0100 Subject: [PATCH] Error out if store is not found when constructing a table in metastore --- .github/workflows/ci.yml | 4 ++-- src/catalog/metastore.rs | 14 ++++---------- src/catalog/mod.rs | 3 +++ src/provider.rs | 1 - 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db2a24e5..2e495127 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: RUSTFLAGS: "-C debuginfo=1" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Setup pre-commit - name: Install pre-commit @@ -20,7 +20,7 @@ jobs: sudo apt-get update sudo apt-get install -y pre-commit - name: Configure pre-commit cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/pre-commit key: pre-commit-${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} diff --git a/src/catalog/metastore.rs b/src/catalog/metastore.rs index f9c341f2..009cdab0 100644 --- a/src/catalog/metastore.rs +++ b/src/catalog/metastore.rs @@ -147,7 +147,9 @@ impl Metastore { let table_log_store = match table.location { // Use the provided customized location Some(location) => { - let store = stores.get(&location).expect("store for location exists"); + let store = stores.get(&location).ok_or(CatalogError::Generic { + reason: format!("Object store for location {location} not found"), + })?; let prefixed_store: PrefixStore> = PrefixStore::new(store.clone(), &*table.path); @@ -220,14 +222,6 @@ impl ObjectStoreFactory for Metastore { url: &Url, _options: &StorageOptions, ) -> DeltaResult<(ObjectStoreRef, Path)> { - if self.default_store.root_uri.scheme() == url.scheme() { - Ok(( - Arc::new(self.default_store.as_ref().clone()), - Path::from("/"), - )) - } else { - // TODO: this won't work if the default store has the same scheme as the queried one - Err(DeltaTableError::InvalidTableLocation(url.clone().into())) - } + Err(DeltaTableError::InvalidTableLocation(url.clone().into())) } } diff --git a/src/catalog/mod.rs b/src/catalog/mod.rs index 22c0ba73..18c4df09 100644 --- a/src/catalog/mod.rs +++ b/src/catalog/mod.rs @@ -21,6 +21,9 @@ pub const STAGING_SCHEMA: &str = "staging"; #[derive(Debug, thiserror::Error)] pub enum CatalogError { + #[error("{reason}")] + Generic { reason: String }, + // Catalog errors #[error("Catalog {name:?} doesn't exist")] CatalogDoesNotExist { name: String }, diff --git a/src/provider.rs b/src/provider.rs index a2ff399b..5516ffd6 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -106,7 +106,6 @@ impl SchemaProvider for SeafowlSchema { if let Err(err) = delta_table.load().await { warn!("Failed to load table {name}: {err}"); - println!("{err}"); return None; }