LiJie20190102 opened a new pull request, #14327:
URL: https://github.com/apache/gravitino/pull/14327

   ### What changes were proposed in this pull request?
   
   - Add `MetalakeMetaService.requireMetalakeByName(String)`, a shared helper 
that looks up a metalake by name and throws `NoSuchEntityException` when it is 
missing.
   - Replace the seven verbatim copies of the "select the metalake by name, 
throw if absent" block with calls to the new helper: the insert paths of 
`CatalogMetaService`, `PolicyMetaService`, `RoleMetaService`, `TagMetaService`, 
`UserMetaService` and `GroupMetaService`, plus the internal usages in 
`MetalakeMetaService` (`getMetalakeByIdentifier`, `updateMetalake`, 
`deleteMetalake`).
   - Remove the `MetalakeMetaMapper` imports that became unused in 
`UserMetaService` and `GroupMetaService`.
   
   Per 
https://github.com/apache/gravitino/issues/12969#issuecomment-6464513436, the 
first item of the issue (backfilling `OccWriteSupport.updateWithVersion`) is 
dropped from the scope, so this PR only covers the shared metalake lookup.
   
   ### Why are the changes needed?
   
   The same ten-line "look up the metalake by name, throw 
`NoSuchEntityException` if missing" block was duplicated across seven services. 
A future change to this error handling would have to be applied seven times, 
and any missed copy would reintroduce exactly the divergence the issue set out 
to remove. Centralising it keeps every caller in sync with one implementation.
   
   This is a pure refactor with no behavioural change: a metalake identifier 
has no namespace, so `ident.toString()` equals `ident.name()` and the exception 
messages are unchanged.
   
   Fix: #12969
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   - `./gradlew :core:test -PskipITs` `--tests 
org.apache.gravitino.storage.relational.service.TestMetalakeMetaService` 
`--tests 
org.apache.gravitino.storage.relational.service.TestCatalogMetaService` 
`--tests org.apache.gravitino.storage.relational.service.TestPolicyMetaService` 
`--tests org.apache.gravitino.storage.relational.service.TestRoleMetaService` 
`--tests org.apache.gravitino.storage.relational.service.TestTagMetaService` 
`--tests org.apache.gravitino.storage.relational.service.TestUserMetaService` 
`--tests org.apache.gravitino.storage.relational.service.TestGroupMetaService` 
(embedded H2 mode, all pass)
   - `./gradlew :core:spotlessCheck :core:compileJava`
   - MySQL/PostgreSQL are covered by CI via the docker-test profile
   
   


-- 
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]

Reply via email to