LuciferYang opened a new pull request, #980: URL: https://github.com/apache/iceberg-cpp/pull/980
## What `InMemoryCatalog` did not correctly check that a table's namespace exists, in two methods. `CreateTable` wrote the table metadata file before validating the namespace. Creating a table under a missing namespace returned `kNoSuchNamespace`, but on object-store `FileIO` it first left an orphaned `00000-<uuid>.metadata.json` that nothing later removes, and on the default local `FileIO` the stray write failed with a misleading `kIOError`. `RegisterTable` guarded with `if (!root_namespace_->NamespaceExists(identifier.ns))`. `NamespaceExists` returns `Result<bool>`, so `!result` tests `has_value()` rather than the bool, and a missing namespace is a value `false`, not an error. The branch was dead code, and a missing namespace surfaced as `kUnknownError` instead of `kNoSuchNamespace`. Closes #977. ## How Both methods now unwrap `root_namespace_->NamespaceExists` and return `kNoSuchNamespace` before any metadata write, matching `SqlCatalog::CreateTable`. The empty (root) namespace still resolves to `true`, so ordinary table creation is unaffected. ## Testing Two new tests in `in_memory_catalog_test.cc`: - `CreateTableNonexistentNamespace` — creating a table under a missing namespace returns `kNoSuchNamespace` and leaves no metadata file behind. It passes an explicit location whose `metadata/` directory already exists, so the pre-fix write lands a detectable orphan there; the zero-file assertion is what fails without the fix. The error-kind assertion alone would still pass pre-fix, because the later `UpdateTableMetadataLocation` also returns `kNoSuchNamespace` after the orphan is written. - `RegisterTableNonexistentNamespace` — registering under a missing namespace returns `kNoSuchNamespace`; without the fix it returned `kUnknownError`. -- 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]
