Repository navigation
feat: Remaining CatalogWarehouseOps & CatalogNamespaceOps - #1444
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughReplaces 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
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)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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. Comment |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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; passstack_messagedirectly toimpl_from_with_detail!.- Change the enum’s
pub fn append_detailto takeimpl Into<String>and delegate to the variant’sappend_detail.- Fully qualify
iceberg_ext::catalog::rest::IcebergErrorResponseinside the macro so call sites don’t need to import it.- If any variant type doesn’t implement
PartialEq, dropPartialEqfrom the enum’s derive.crates/authz-openfga/src/api.rs (1)
1649-1657: Test helper: consider explicit WarehouseId constructorOptional: 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 contextUsing |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 collectionYou 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 lookupThis 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 checkYou 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
📒 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
.namespaceto.namespace_identmakes the field name more explicit and aligns with the PR-wide refactor replacingGetNamespaceResponsewithNamespace. 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 correctSwitch 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 goodRe-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 correctAllowAll 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 correctConsistent 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 LGTMSignature 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 NamespaceUsing Arc::unwrap_or_clone and inserting namespace_id property before responding is correct and efficient. LGTM.
331-338: Load metadata: property extraction LGTMGood 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 NamespaceImports 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 &NamespaceAligned with the broader type migration. No functional issues.
crates/authz-openfga/src/authorizer.rs (1)
15-17: Namespace type swap looks correctImports 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: OKrequire_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 goodSignatures 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/CreateNamespaceResponsereturned 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
Namespaceinstead 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
DatabaseIntegrityErrorwith 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_URLare 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:
DATABASE_URLis set in the CI environment, or- Run
cargo sqlx prepareto generate/update the query cache for offline compilationThe 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
Namespacetype instead of response objects- Match on specific
Catalog*Errorvariants for better error verification- Include the
warehouse_idparameter inset_namespace_protectedcallsThe test coverage remains comprehensive and correctly validates the new API surface.
✅ Actions performedComments resolved and changes approved. |
✅ PR Title Formatted CorrectlyThe title of this PR match the correct format. Thank you! |
Summary by CodeRabbit
New Features
Refactor
Tests