blackmwk commented on code in PR #2131: URL: https://github.com/apache/iceberg-rust/pull/2131#discussion_r2792627085
########## crates/catalog/loader/tests/namespace_suite.rs: ########## @@ -0,0 +1,358 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Common namespace behavior across catalogs. +//! +//! These tests assume Docker containers are started externally via `make docker-up`. + +mod common; + +use std::collections::HashMap; + +use common::{CatalogKind, assert_map_contains, cleanup_namespace_dyn, load_catalog}; +use iceberg::{ErrorKind, NamespaceIdent, Result}; +use iceberg_test_utils::normalize_test_name_with_parts; +use rstest::rstest; + +// Common behavior: querying a missing namespace should error. +#[rstest] +#[case::rest_catalog(CatalogKind::Rest)] +#[case::glue_catalog(CatalogKind::Glue)] +#[case::hms_catalog(CatalogKind::Hms)] +#[case::sql_catalog(CatalogKind::Sql)] +#[case::s3tables_catalog(CatalogKind::S3Tables)] +#[case::memory_catalog(CatalogKind::Memory)] +#[tokio::test] +async fn test_catalog_namespace_missing_returns_error(#[case] kind: CatalogKind) -> Result<()> { + let Some(harness) = load_catalog(kind).await else { + return Ok(()); + }; + let catalog = harness.catalog; + let namespace = NamespaceIdent::new(normalize_test_name_with_parts!( + "catalog_namespace_missing_returns_error", + harness.label + )); + + cleanup_namespace_dyn(catalog.as_ref(), &namespace).await; + + assert!(catalog.get_namespace(&namespace).await.is_err()); Review Comment: Fixed. ########## crates/catalog/hms/src/catalog.rs: ########## @@ -520,6 +545,15 @@ impl Catalog for HmsCatalog { /// - Any network or communication error occurs with the database backend. async fn drop_table(&self, table: &TableIdent) -> Result<()> { let db_name = validate_namespace(table.namespace())?; + if !self.namespace_exists(table.namespace()).await? { + return Err(Error::new( + ErrorKind::DataInvalid, + "Namespace does not exist", + )); + } + if !self.table_exists(table).await? { + return Err(Error::new(ErrorKind::DataInvalid, "Table does not exist")); Review Comment: Fixed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
