Skip to content

feat: Remaining CatalogWarehouseOps & CatalogNamespaceOps - #1444

Merged
c-thiel merged 7 commits into
ct/warehouse-cachefrom
ct/warehouse-write
Oct 15, 2025
Merged

c-thiel merged 7 commits into
ct/warehouse-cachefrom
ct/warehouse-write

Conversation

@c-thiel

@c-thiel c-thiel commented Oct 14, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Unified Namespace object now returned across the app with richer metadata (identifier, IDs, protection, properties, timestamps).
    • Added/expanded namespace operations: create, drop, update properties, set protection.
    • Warehouse operations enhanced: set deletion profile, status, protection, and update storage profile; protection updates return a ProtectionResponse.
  • Refactor

    • Replaced legacy namespace response with the new Namespace type in APIs, listings, and authorization checks.
    • Standardized errors with specific, user-friendly error types for catalog and warehouse actions, improving clarity and consistency.
  • Tests

    • Updated to align with new types and signatures.

@coderabbitai

coderabbitai Bot commented Oct 14, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Replaces GetNamespaceResponse with Namespace across services, authz, server, and Postgres implementations. Introduces specific Catalog* error enums via a new define_transparent_error macro. Adjusts CatalogStore trait signatures (adds *_impl methods), updates warehouse error types, and modifies set_namespace_protected to accept warehouse_id and return Namespace.

Changes

Cohort / File(s) Summary
Namespace domain + errors
crates/lakekeeper/src/service/catalog_store/namespace.rs, crates/lakekeeper/src/service/catalog_store/error.rs, crates/lakekeeper/src/service/catalog_store/warehouse.rs
Replace GetNamespaceResponse with Namespace struct; add Catalog* error enums via define_transparent_error; introduce simple namespace errors; extend CatalogNamespaceOps with create/drop/update/protect; add StorageProfileSerializationError and warehouse error enums.
Postgres implementations
crates/lakekeeper/src/implementations/postgres/namespace.rs, .../postgres/catalog.rs, .../postgres/warehouse.rs
Update return/param types to Namespace; broaden errors to new Catalog* enums; rename methods to *_impl; adjust list_tables namespace param; refine warehouse operation error types and mappings.
CatalogStore trait surface
crates/lakekeeper/src/service/catalog_store.rs
Rename methods to *_impl; switch to std::result::Result with specific error enums; migrate namespace params/returns to Namespace; adjust list_tables/list_views to accept &Namespace.
Authz traits and impls
crates/lakekeeper/src/service/authz/mod.rs, .../authz/namespace.rs, .../authz/implementations/allow_all.rs
Change namespace parameter types from &GetNamespaceResponse to &Namespace for single/batch checks; update trait signatures and tests accordingly.
OpenFGA integration
crates/authz-openfga/src/authorizer.rs, crates/authz-openfga/src/api.rs
Replace GetNamespaceResponse with Namespace in imports and method signatures; test helper random_namespace now returns Namespace.
Server modules/tests
crates/lakekeeper/src/server/tabular.rs, .../server/namespace.rs, .../server/views.rs, .../server/views/create.rs, .../server/views/rename.rs, .../server/mod.rs
Update functions/tests to use Namespace type and namespace_ident field; adjust setup helpers and determine_tabular_location signature.
API management adjustment
crates/lakekeeper/src/api/management/v1/namespace.rs
set_namespace_protected now passes warehouse_id and returns ProtectionResponse constructed from status; aligns with backend signature accepting warehouse_id.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Server
  participant CatalogStore
  participant Postgres

  Note over Server,CatalogStore: Set namespace protection (signature changed)
  Client->>Server: PUT /namespaces/{warehouse_id}/{namespace_id}/protected
  Server->>CatalogStore: set_namespace_protected_impl(warehouse_id, namespace_id, protect)
  CatalogStore->>Postgres: set_namespace_protected(warehouse_id, namespace_id, protect, tx)
  Postgres-->>CatalogStore: Namespace
  CatalogStore-->>Server: Namespace
  Server-->>Client: Namespace (includes namespace_ident, ids, protected, properties)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • mooori

Poem

In burrows of code, I twitch my nose,
Old names hop out, new Namespace grows.
Errors align, stacked neat in rows,
Warehouses guarded, as logic flows.
With paws on tests, I swiftly compose—
Thump! Refactors done; the garden shows. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.19% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly indicates that the pull request implements the remaining methods for the CatalogWarehouseOps and CatalogNamespaceOps traits, succinctly summarizing the main functional addition without extraneous details.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@c-thiel

c-thiel commented Oct 14, 2025

Copy link
Copy Markdown
Member Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Oct 14, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (6)
crates/lakekeeper/src/service/catalog_store/error.rs (1)

53-109: Refactor define_transparent_error macro for hygiene and ergonomics

  • Remove the paste-generated const; pass stack_message directly to impl_from_with_detail!.
  • Change the enum’s pub fn append_detail to take impl Into<String> and delegate to the variant’s append_detail.
  • Fully qualify iceberg_ext::catalog::rest::IcebergErrorResponse inside the macro so call sites don’t need to import it.
  • If any variant type doesn’t implement PartialEq, drop PartialEq from the enum’s derive.
crates/authz-openfga/src/api.rs (1)

1649-1657: Test helper: consider explicit WarehouseId constructor

Optional: if a WarehouseId::nil() (or equivalent) exists, prefer that over uuid::Uuid::nil().into() for clarity. Otherwise, this is fine.

crates/lakekeeper/src/server/namespace.rs (2)

141-177: Minor readability: closure var name clashes with surrounding context

Using |id| for elements of responses while ids is also in scope is slightly confusing. Rename to ns (or namespace) for clarity.

-                            .map(|id| (id, CatalogNamespaceAction::CanGetMetadata))
+                            .map(|ns| (ns, CatalogNamespaceAction::CanGetMetadata))

195-201: Style nit: simpler UUID collection

You can avoid the map(|s| *s) by using copied():

-            namespace_uuids: return_uuids.then_some(ids.into_iter().map(|s| *s).collect()),
+            namespace_uuids: return_uuids.then_some(ids.iter().copied().collect()),
crates/lakekeeper/src/server/tabular.rs (1)

31-37: Avoid cloning entire namespace properties for location lookup

This clones the full properties map just to read location. Consider reading the "location" key directly and parsing, to avoid cloning the entire HashMap. For example:

-        let namespace_props = NamespaceProperties::from_props_unchecked(
-            namespace
-                .properties
-                .as_ref()
-                .map(|arc| (**arc).clone())
-                .unwrap_or_default(),
-        );
-
-        let namespace_location = match namespace_props.get_location() {
+        let namespace_location = match namespace
+            .properties
+            .as_ref()
+            .and_then(|props| props.get("location").cloned())
+            .map(|s| parse_location(&s, StatusCode::INTERNAL_SERVER_ERROR))
+            .transpose()?
+        {
             Some(location) => location,
             None => storage_profile
                 .default_namespace_location(namespace.namespace_id)
                 .map_err(|e| {
                     ErrorModel::internal(
                         "Failed to generate default namespace location",
                         "InvalidDefaultNamespaceLocation",
                         Some(Box::new(e)),
                     )
                 })?,
         };

If keeping NamespaceProperties is preferred, consider adding a helper that accepts &HashMap to avoid cloning (e.g., from_props_ref), in a follow-up.

crates/lakekeeper/src/service/authz/mod.rs (1)

395-411: Avoid cloning Namespace in batch check

You clone Namespace per item. Borrow it directly to reduce allocations.

Apply this diff:

-        let futures: Vec<_> = actions
-            .iter()
-            .map(|(ns, a)| async move {
-                let namespace = (*ns).clone();
-                self.is_allowed_namespace_action(metadata, &namespace, *a)
-                    .await
-                    .map(MustUse::into_inner)
-            })
-            .collect();
-        let results = try_join_all(futures).await?;
+        let results: Vec<bool> = try_join_all(
+            actions
+                .iter()
+                .map(|(ns, a)| self.is_allowed_namespace_action(metadata, *ns, *a)),
+        )
+        .await?
+        .into_iter()
+        .map(MustUse::into_inner)
+        .collect();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae2b14 and 5c96d38.

📒 Files selected for processing (19)
  • crates/authz-openfga/src/api.rs (2 hunks)
  • crates/authz-openfga/src/authorizer.rs (3 hunks)
  • crates/lakekeeper/src/api/management/v1/namespace.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/catalog.rs (7 hunks)
  • crates/lakekeeper/src/implementations/postgres/namespace.rs (34 hunks)
  • crates/lakekeeper/src/implementations/postgres/warehouse.rs (21 hunks)
  • crates/lakekeeper/src/server/mod.rs (2 hunks)
  • crates/lakekeeper/src/server/namespace.rs (3 hunks)
  • crates/lakekeeper/src/server/tabular.rs (2 hunks)
  • crates/lakekeeper/src/server/views.rs (4 hunks)
  • crates/lakekeeper/src/server/views/create.rs (1 hunks)
  • crates/lakekeeper/src/server/views/rename.rs (1 hunks)
  • crates/lakekeeper/src/service/authz/implementations/allow_all.rs (2 hunks)
  • crates/lakekeeper/src/service/authz/mod.rs (5 hunks)
  • crates/lakekeeper/src/service/authz/namespace.rs (5 hunks)
  • crates/lakekeeper/src/service/catalog_store.rs (3 hunks)
  • crates/lakekeeper/src/service/catalog_store/error.rs (2 hunks)
  • crates/lakekeeper/src/service/catalog_store/namespace.rs (8 hunks)
  • crates/lakekeeper/src/service/catalog_store/warehouse.rs (6 hunks)
🧰 Additional context used
🪛 GitHub Check: check-generated-openapi-matches
crates/lakekeeper/src/implementations/postgres/namespace.rs

[failure] 308-308:
set DATABASE_URL to use query macros online, or run cargo sqlx prepare to update the query cache


[failure] 577-577:
set DATABASE_URL to use query macros online, or run cargo sqlx prepare to update the query cache


[failure] 623-623:
set DATABASE_URL to use query macros online, or run cargo sqlx prepare to update the query cache

🪛 GitHub Check: clippy
crates/lakekeeper/src/implementations/postgres/namespace.rs

[failure] 308-308:
set DATABASE_URL to use query macros online, or run cargo sqlx prepare to update the query cache


[failure] 577-577:
set DATABASE_URL to use query macros online, or run cargo sqlx prepare to update the query cache


[failure] 623-623:
set DATABASE_URL to use query macros online, or run cargo sqlx prepare to update the query cache

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: test
  • GitHub Check: sqlx-check
🔇 Additional comments (20)
crates/lakekeeper/src/server/views/rename.rs (1)

189-189: LGTM! Field access update aligns with the broader refactor.

The change from .namespace to .namespace_ident makes the field name more explicit and aligns with the PR-wide refactor replacing GetNamespaceResponse with Namespace. Since this is test-only code and Rust's type system enforces correctness, this change is safe.

crates/lakekeeper/src/server/views/create.rs (1)

290-291: Namespace API rename looks correct

Switch to .namespace_ident matches the new Namespace type and expected NamespaceIdent in helper.

crates/lakekeeper/src/service/catalog_store/error.rs (1)

137-138: Re-export is good

Re-exporting the macro pub(crate) use define_transparent_error; is appropriate.

crates/lakekeeper/src/service/authz/implementations/allow_all.rs (1)

19-21: Namespace type switch is correct

AllowAll authorizer compiles against the new trait shape using &Namespace. No further changes needed.

Also applies to: 141-145

crates/lakekeeper/src/server/views.rs (1)

163-163: Test updates align with new Namespace surface

  • Imported Namespace in tests.
  • Using .namespace_ident and passing &Namespace to list_views helpers is consistent.

Also applies to: 196-196, 224-232, 250-258

crates/authz-openfga/src/api.rs (1)

1636-1636: Import switch to Namespace looks correct

Consistent with the repo-wide type migration. No issues.

crates/lakekeeper/src/api/management/v1/namespace.rs (1)

49-58: Updated set_namespace_protected call and response mapping LGTM

Signature change (warehouse_id first) and returning ProtectionResponse derived from status are consistent and correct.

Please confirm that CatalogNamespaceAction::CanDelete is the intended permission to guard protection changes (vs. a more specific action like CanSetProtection/CanUpdateProperties) in your model.

crates/lakekeeper/src/server/namespace.rs (2)

286-301: Create flow updated to return CreateNamespaceResponse from Namespace

Using Arc::unwrap_or_clone and inserting namespace_id property before responding is correct and efficient. LGTM.


331-338: Load metadata: property extraction LGTM

Good use of Arc::unwrap_or_clone and consistent inclusion of the namespace_id property in the response.

crates/lakekeeper/src/server/mod.rs (1)

270-271: Test surface migrated to Namespace

Imports and tabular_test_multi_warehouse_setup return type updated consistently. Looks good.

Also applies to: 372-373

crates/lakekeeper/src/server/tabular.rs (1)

18-22: Signature switch to &Namespace

Aligned with the broader type migration. No functional issues.

crates/authz-openfga/src/authorizer.rs (1)

15-17: Namespace type swap looks correct

Imports and method signatures updated to use Namespace, and checks use namespace.namespace_id consistently. No issues spotted.

Also applies to: 321-331, 336-347

crates/lakekeeper/src/service/authz/namespace.rs (1)

10-12: AuthZ ops updated to Namespace: OK

require_namespace_action, single/batch namespace checks, and conversions all align with the new domain type. The batch mapping passes &Namespace correctly.

Also applies to: 170-173, 215-225, 233-249, 256-269

crates/lakekeeper/src/implementations/postgres/catalog.rs (1)

119-121: Postgres CatalogStore impls return domain Namespace: looks good

Signatures and return/error types updated coherently. list_tables/list_views now accept &Namespace and correctly use warehouse_id/namespace_id. Warehouse ops now return specific error types.

Also applies to: 124-131, 137-139, 141-148, 150-157, 167-180, 566-579, 675-683, 684-691, 488-494, 504-510, 512-525

crates/lakekeeper/src/service/catalog_store/namespace.rs (1)

5-13: Approve namespace service changes

  • Search for GetNamespaceResponse/CreateNamespaceResponse returned only expected references in OpenAPI spec, API modules, server implementation, and tests (all new API types).
  • No legacy types remain; no blockers.
crates/lakekeeper/src/service/authz/mod.rs (1)

15-16: Interface migration to Namespace is consistent
No stale GetNamespaceResponse references remain in crates/lakekeeper/src/service/authz.

crates/lakekeeper/src/implementations/postgres/namespace.rs (4)

30-87: LGTM - consistent return type migration.

The functions now correctly return Namespace instead of the previous response type. The inline struct construction is appropriate and all required fields are properly populated.


537-568: LGTM - improved error handling.

The function now returns DatabaseIntegrityError with more descriptive error messages, which provides better debugging information when namespace identifiers are malformed.


308-308: Static analysis warning - CI environment issue.

The static analysis warnings about DATABASE_URL are build environment issues, not code defects. The sqlx query macros require a database connection at compile-time for verification. To resolve these warnings, ensure that either:

  1. DATABASE_URL is set in the CI environment, or
  2. Run cargo sqlx prepare to generate/update the query cache for offline compilation

The SQL queries themselves are syntactically correct.

Also applies to: 577-577, 623-623


658-1396: LGTM - comprehensive test updates.

All tests have been properly updated to:

  • Use the new Namespace type instead of response objects
  • Match on specific Catalog*Error variants for better error verification
  • Include the warehouse_id parameter in set_namespace_protected calls

The test coverage remains comprehensive and correctly validates the new API surface.

@coderabbitai

coderabbitai Bot commented Oct 14, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Comments resolved and changes approved.

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant