Skip to content

Commit

Permalink
Error out if store is not found when constructing a table in metastore
Browse files Browse the repository at this point in the history
  • Loading branch information
gruuya committed Feb 28, 2024
1 parent 2a5f5a7 commit b22c40b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
RUSTFLAGS: "-C debuginfo=1"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Setup pre-commit
- name: Install pre-commit
run: |
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') }}
Expand Down
14 changes: 4 additions & 10 deletions src/catalog/metastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Arc<dyn ObjectStore>> =
PrefixStore::new(store.clone(), &*table.path);

Expand Down Expand Up @@ -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()))
}
}
3 changes: 3 additions & 0 deletions src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 0 additions & 1 deletion src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b22c40b

Please sign in to comment.