World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
Revert #8255 update group changes (#8265)
Justin Mclean755f0caf5e64
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java b/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.javaindex 14fec721e1..4329b3a0a1 100644--- a/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java+++ b/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java@@ -210,6 +210,9 @@ public class GroupMetaService {Set<Long> insertRoleIds = Sets.difference(newRoleIds, oldRoleIds);Set<Long> deleteRoleIds = Sets.difference(oldRoleIds, newRoleIds);+ if (insertRoleIds.isEmpty() && deleteRoleIds.isEmpty()) {+ return newEntity;+ }try {SessionUtils.doMultipleWithCommit(() ->@@ -220,23 +223,25 @@ public class GroupMetaService {POConverters.updateGroupPOWithVersion(oldGroupPO, newEntity),oldGroupPO)),() -> {- if (!insertRoleIds.isEmpty()) {- SessionUtils.doWithoutCommit(- GroupRoleRelMapper.class,- mapper ->- mapper.batchInsertGroupRoleRel(- POConverters.initializeGroupRoleRelsPOWithVersion(- newEntity, Lists.newArrayList(insertRoleIds))));+ if (insertRoleIds.isEmpty()) {+ return;}+ SessionUtils.doWithoutCommit(+ GroupRoleRelMapper.class,+ mapper ->+ mapper.batchInsertGroupRoleRel(+ POConverters.initializeGroupRoleRelsPOWithVersion(+ newEntity, Lists.newArrayList(insertRoleIds))));},() -> {- if (!deleteRoleIds.isEmpty()) {- SessionUtils.doWithoutCommit(- GroupRoleRelMapper.class,- mapper ->- mapper.softDeleteGroupRoleRelByGroupAndRoles(- newEntity.id(), Lists.newArrayList(deleteRoleIds)));+ if (deleteRoleIds.isEmpty()) {+ return;}+ SessionUtils.doWithoutCommit(+ GroupRoleRelMapper.class,+ mapper ->+ mapper.softDeleteGroupRoleRelByGroupAndRoles(+ newEntity.id(), Lists.newArrayList(deleteRoleIds)));});} catch (RuntimeException re) {ExceptionUtils.checkSQLException(diff --git a/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.java b/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.javaindex a5ab960693..5e90f0eb89 100644--- a/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.java+++ b/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.java@@ -1012,44 +1012,4 @@ class TestGroupMetaService extends TestJDBCBackend {}return count;}-- @Test- void updateGroupWithoutRoleChange() throws IOException {- AuditInfo auditInfo =- AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build();- BaseMetalake metalake =- createBaseMakeLake(RandomIdGenerator.INSTANCE.nextId(), metalakeName, auditInfo);- backend.insert(metalake, false);-- GroupMetaService groupMetaService = GroupMetaService.getInstance();-- GroupEntity group1 =- createGroupEntity(- RandomIdGenerator.INSTANCE.nextId(),- AuthorizationUtils.ofGroupNamespace(metalakeName),- "group1",- auditInfo);- groupMetaService.insertGroup(group1, false);-- Function<GroupEntity, GroupEntity> renameUpdater =- group ->- GroupEntity.builder()- .withNamespace(group.namespace())- .withId(group.id())- .withName("group_renamed")- .withRoleNames(group.roleNames())- .withRoleIds(group.roleIds())- .withAuditInfo(group.auditInfo())- .build();- groupMetaService.updateGroup(group1.nameIdentifier(), renameUpdater);-- Assertions.assertThrows(- NoSuchEntityException.class,- () -> groupMetaService.getGroupByIdentifier(group1.nameIdentifier()));-- GroupEntity updated =- groupMetaService.getGroupByIdentifier(- AuthorizationUtils.ofGroup(metalakeName, "group_renamed"));- Assertions.assertEquals("group_renamed", updated.name());- }}