World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#15016] feat(domain): Make a domain's backing tag a tag name without a value (#15025)
Jerry Shao20f5bcb95df4
diff --git a/api/src/main/java/org/apache/gravitino/domain/Domain.java b/api/src/main/java/org/apache/gravitino/domain/Domain.javaindex 4d3ba65793..094a2f5c46 100644--- a/api/src/main/java/org/apache/gravitino/domain/Domain.java+++ b/api/src/main/java/org/apache/gravitino/domain/Domain.java@@ -29,16 +29,14 @@ import org.apache.gravitino.exceptions.ForbiddenException;import org.apache.gravitino.exceptions.NoSuchDomainException;import org.apache.gravitino.exceptions.NoSuchTagException;import org.apache.gravitino.exceptions.TagAlreadyExistsException;-import org.apache.gravitino.tag.TagValue;/*** A domain groups metadata objects from any catalog under a business name, such as "Finance". A* leaf metadata object, of a type in {@link DomainMember#SUPPORTED_TYPES}, is a member of a domain* when it carries the domain's backing tag, directly or inherited from its catalog or schema. The- * default member listing includes catalogs and schemas that directly carry a backing tag. For a- * leaf object, the nearest assignment of the same tag wins: a table that carries {@code dept=hr}- * under a schema that carries {@code dept=finance} is a member of the domain backed by {@code- * dept=hr} only.+ * default member listing includes catalogs and schemas that directly carry a backing tag.+ * Membership depends only on the presence of the backing tag: a value on an assignment of the tag+ * is ignored.** <p>Names have 1 to 64 ASCII letters, digits, underscores or hyphens and may not start with a* hyphen. The names {@code *} and {@code system} (in any letter case) are reserved.@@ -111,18 +109,17 @@ public interface Domain extends Auditable {Optional<String> parent();/**- * Returns the backing tag of the domain. The metadata objects whose effective assignment of this- * tag matches it are the members of the domain. A backing tag without a value matches every- * assignment of the tag, with or without values. A backing tag with a value matches the- * assignments whose values contain it, compared exactly and case-sensitively.+ * Returns the name of the backing tag of the domain. The metadata objects that carry this tag,+ * with or without values, are the members of the domain; any value on an assignment of the tag is+ * ignored. A tag backs at most one domain.** <p>The domain refers to the tag itself, not to its name: a renamed tag keeps backing the* domain, and a new tag with the name of a deleted one does not.*- * @return The backing tag of the domain, or empty if the backing tag has been removed or deleted- * and no new one has been set.+ * @return The name of the backing tag of the domain, or empty if the backing tag has been removed+ * or deleted and no new one has been set.*/- Optional<TagValue> backingTag();+ Optional<String> backingTag();/*** Returns how the metadata object relates to this domain. It is set only on the domains returned@@ -194,18 +191,17 @@ public interface Domain extends Auditable {* snapshot shows. Members are not migrated: objects that carry only the old backing tag are no* longer members of the domain. Setting the current backing tag has no effect.*- * @param backingTag The existing tag, with an optional value, that backs the domain, or null to- * remove the backing tag.+ * @param backingTag The name of the existing tag that backs the domain, or null to remove the+ * backing tag.* @return The updated domain.* @throws NoSuchDomainException If this domain does not exist or is not visible to the caller.* @throws NoSuchTagException If the tag does not exist.- * @throws BackingTagAlreadyBoundException If the binding conflicts with the backing tag of- * another domain.+ * @throws BackingTagAlreadyBoundException If the tag already backs another domain.* @throws ForbiddenException If a tag is set and the caller owns neither the tag nor the* metalake. Removing the backing tag needs no privilege on the tag.- * @throws IllegalArgumentException If the value is not allowed by the tag.+ * @throws IllegalArgumentException If the tag name is blank.*/- Domain updateBackingTag(@Nullable TagValue backingTag)+ Domain updateBackingTag(@Nullable String backingTag)throws NoSuchDomainException, NoSuchTagException, BackingTagAlreadyBoundException,ForbiddenException, IllegalArgumentException;@@ -214,7 +210,7 @@ public interface Domain extends Auditable {** <p>The backing tag is always given explicitly. With {@code createBackingTag} set, a new tag* without values is created with the given name and owned by the caller; otherwise the given- * existing tag, with its optional value, is bound. An existing tag is never adopted implicitly.+ * existing tag is bound, whatever values it allows. An existing tag is never adopted implicitly.** <p>The sub-domain, a new backing tag and the link to this domain are created together: if the* creation fails, none of them is created, and an existing tag to bind is left unchanged.@@ -222,27 +218,25 @@ public interface Domain extends Auditable {* @param name The name of the sub-domain.* @param comment The comment of the sub-domain, or null.* @param properties The properties of the sub-domain, or null.- * @param backingTag The backing tag of the sub-domain: the name of the tag to create, or an- * existing tag with an optional value.+ * @param backingTag The name of the backing tag of the sub-domain: the tag to create, or an+ * existing tag.* @param createBackingTag Whether to create the backing tag as a new tag.* @return The created sub-domain.* @throws NoSuchDomainException If this domain does not exist or is not visible to the caller.* @throws DomainAlreadyExistsException If a domain with the same name already exists.* @throws NoSuchTagException If the existing backing tag to bind does not exist.* @throws TagAlreadyExistsException If the backing tag to create already exists.- * @throws BackingTagAlreadyBoundException If the binding conflicts with the backing tag of- * another domain.+ * @throws BackingTagAlreadyBoundException If the existing tag already backs another domain.* @throws ForbiddenException If the caller does not own the existing backing tag or the metalake,* or may not create tags.- * @throws IllegalArgumentException If the backing tag is null, a value is given for a tag to- * create, the value is not allowed by the existing tag, this domain is itself a sub-domain,- * or the sub-domain cannot be created under this domain.+ * @throws IllegalArgumentException If the backing tag is null or blank, this domain is itself a+ * sub-domain, or the sub-domain cannot be created under this domain.*/Domain createSubdomain(String name,@Nullable String comment,@Nullable Map<String, String> properties,- TagValue backingTag,+ String backingTag,boolean createBackingTag)throws NoSuchDomainException, DomainAlreadyExistsException, NoSuchTagException,TagAlreadyExistsException, BackingTagAlreadyBoundException, ForbiddenException,diff --git a/api/src/main/java/org/apache/gravitino/domain/DomainOperations.java b/api/src/main/java/org/apache/gravitino/domain/DomainOperations.javaindex 3992847edb..7baee51f6d 100644--- a/api/src/main/java/org/apache/gravitino/domain/DomainOperations.java+++ b/api/src/main/java/org/apache/gravitino/domain/DomainOperations.java@@ -29,7 +29,6 @@ import org.apache.gravitino.exceptions.NoSuchMetalakeException;import org.apache.gravitino.exceptions.NoSuchTagException;import org.apache.gravitino.exceptions.NonEmptyDomainException;import org.apache.gravitino.exceptions.TagAlreadyExistsException;-import org.apache.gravitino.tag.TagValue;/*** Interface for the domain operations of a metalake. Operations on a single domain, such as@@ -69,11 +68,12 @@ public interface DomainOperations {/*** Creates a top-level domain in {@link Domain.Status#DRAFT} status. Use {@link- * Domain#createSubdomain(String, String, Map, TagValue, boolean)} to create a sub-domain.+ * Domain#createSubdomain(String, String, Map, String, boolean)} to create a sub-domain.** <p>The backing tag is always given explicitly. With {@code createBackingTag} set, a new tag* without values is created with the given name and owned by the caller; otherwise the given- * existing tag, with its optional value, is bound. An existing tag is never adopted implicitly.+ * existing tag is bound, whatever values it allows. An existing tag is never adopted implicitly.+ * A tag backs at most one domain.** <p>The domain and a new backing tag are created together: if the creation fails, neither is* created, and an existing tag to bind is left unchanged.@@ -81,25 +81,23 @@ public interface DomainOperations {* @param name The name of the domain.* @param comment The comment of the domain, or null.* @param properties The properties of the domain, or null.- * @param backingTag The backing tag of the domain: the name of the tag to create, or an existing- * tag with an optional value.+ * @param backingTag The name of the backing tag of the domain: the tag to create, or an existing+ * tag.* @param createBackingTag Whether to create the backing tag as a new tag.* @return The created domain.* @throws DomainAlreadyExistsException If a domain with the same name already exists.* @throws NoSuchTagException If the existing backing tag to bind does not exist.* @throws TagAlreadyExistsException If the backing tag to create already exists.- * @throws BackingTagAlreadyBoundException If the binding conflicts with the backing tag of- * another domain.+ * @throws BackingTagAlreadyBoundException If the existing tag already backs another domain.* @throws ForbiddenException If the caller does not own the existing backing tag or the metalake,* or may not create tags.- * @throws IllegalArgumentException If the backing tag is null, a value is given for a tag to- * create, or the value is not allowed by the existing tag.+ * @throws IllegalArgumentException If the backing tag is null or blank.*/Domain createDomain(String name,@Nullable String comment,@Nullable Map<String, String> properties,- TagValue backingTag,+ String backingTag,boolean createBackingTag)throws DomainAlreadyExistsException, NoSuchTagException, TagAlreadyExistsException,BackingTagAlreadyBoundException, ForbiddenException, IllegalArgumentException;diff --git a/clients/client-java/src/main/java/org/apache/gravitino/client/GenericDomain.java b/clients/client-java/src/main/java/org/apache/gravitino/client/GenericDomain.javaindex 5b24f3e76c..15c71ecd0c 100644--- a/clients/client-java/src/main/java/org/apache/gravitino/client/GenericDomain.java+++ b/clients/client-java/src/main/java/org/apache/gravitino/client/GenericDomain.java@@ -49,7 +49,6 @@ import org.apache.gravitino.dto.responses.DomainMemberListResponse;import org.apache.gravitino.dto.responses.DomainResponse;import org.apache.gravitino.dto.responses.NameListResponse;import org.apache.gravitino.rest.RESTUtils;-import org.apache.gravitino.tag.TagValue;/** A domain snapshot with operations addressed by its name. */class GenericDomain implements Domain {@@ -96,8 +95,13 @@ class GenericDomain implements Domain {/** {@inheritDoc} */@Override- public Optional<TagValue> backingTag() {- return Optional.ofNullable(domain.getBackingTag()).map(DomainBackingTagDTO::tagValue);+ public Optional<String> backingTag() {+ return Optional.ofNullable(domain.getBackingTag())+ .map(+ tag -> {+ tag.validate();+ return tag.getName();+ });}/** {@inheritDoc} */@@ -151,12 +155,10 @@ class GenericDomain implements Domain {/** {@inheritDoc} */@Override- public Domain updateBackingTag(@Nullable TagValue backingTag) {+ public Domain updateBackingTag(@Nullable String backingTag) {DomainBackingTagSetRequest request =new DomainBackingTagSetRequest(- backingTag == null- ? null- : new DomainBackingTagDTO(backingTag.name(), backingTag.value().orElse(null)));+ backingTag == null ? null : new DomainBackingTagDTO(backingTag));request.validate();return snapshot(restClient.put(@@ -173,7 +175,7 @@ class GenericDomain implements Domain {String name,@Nullable String comment,@Nullable Map<String, String> properties,- TagValue backingTag,+ String backingTag,boolean createBackingTag) {Preconditions.checkArgument(backingTag != null, "backingTag must not be null");DomainCreateRequest request =@@ -182,8 +184,7 @@ class GenericDomain implements Domain {comment,properties,name(),- new DomainCreateRequest.BackingTag(- backingTag.name(), backingTag.value().orElse(null), createBackingTag));+ new DomainCreateRequest.BackingTag(backingTag, createBackingTag));request.validate();DomainResponse response =restClient.post(diff --git a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.javaindex 64cb6d6046..3cc0a78c30 100644--- a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java+++ b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java@@ -152,7 +152,6 @@ import org.apache.gravitino.secret.SupportsSecrets;import org.apache.gravitino.tag.Tag;import org.apache.gravitino.tag.TagChange;import org.apache.gravitino.tag.TagOperations;-import org.apache.gravitino.tag.TagValue;import org.apache.gravitino.tag.TagValueConstraint;/**@@ -1084,7 +1083,7 @@ public class GravitinoMetalake extends MetalakeDTOString name,@Nullable String comment,@Nullable Map<String, String> properties,- TagValue backingTag,+ String backingTag,boolean createBackingTag) {Preconditions.checkArgument(backingTag != null, "backingTag must not be null");DomainCreateRequest request =@@ -1093,8 +1092,7 @@ public class GravitinoMetalake extends MetalakeDTOcomment,properties,null,- new DomainCreateRequest.BackingTag(- backingTag.name(), backingTag.value().orElse(null), createBackingTag));+ new DomainCreateRequest.BackingTag(backingTag, createBackingTag));request.validate();DomainResponse response =restClient.post(diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/TestDomainOperations.java b/clients/client-java/src/test/java/org/apache/gravitino/client/TestDomainOperations.javaindex 349debfbed..5daf55cb53 100644--- a/clients/client-java/src/test/java/org/apache/gravitino/client/TestDomainOperations.java+++ b/clients/client-java/src/test/java/org/apache/gravitino/client/TestDomainOperations.java@@ -53,7 +53,6 @@ import org.apache.gravitino.exceptions.NoSuchTagException;import org.apache.gravitino.exceptions.NonEmptyDomainException;import org.apache.gravitino.exceptions.TagAlreadyExistsException;import org.apache.gravitino.rest.RESTUtils;-import org.apache.gravitino.tag.TagValue;import org.apache.hc.core5.http.Method;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;@@ -81,7 +80,7 @@ public class TestDomainOperations extends TestBase {@Testpublic void testMetalakeOperations() throws Exception {GravitinoMetalake metalake = metalake();- DomainDTO dto = dto(NAME, Domain.Status.DRAFT, null, TagValue.of("dept", "finance"));+ DomainDTO dto = dto(NAME, Domain.Status.DRAFT, null, "dept");buildMockResource(Method.POST,ROOT,@@ -90,12 +89,10 @@ public class TestDomainOperations extends TestBase {"comment",Collections.emptyMap(),null,- new DomainCreateRequest.BackingTag("dept", "finance", false)),+ new DomainCreateRequest.BackingTag("dept", false)),new DomainResponse(dto),200);- Domain created =- metalake.createDomain(- NAME, "comment", Collections.emptyMap(), TagValue.of("dept", "finance"), false);+ Domain created = metalake.createDomain(NAME, "comment", Collections.emptyMap(), "dept", false);assertSnapshot(created, dto);buildMockResource(Method.GET, ROOT, null, new NameListResponse(new String[] {NAME}), 200);Assertions.assertArrayEquals(new String[] {NAME}, metalake.listDomains());@@ -117,9 +114,7 @@ public class TestDomainOperations extends TestBase {Assertions.assertNotEquals(loaded,new GenericDomain(- dto(NAME, Domain.Status.PUBLISHED, null, TagValue.of("dept", "finance")),- client.restClient(),- "metalake"));+ dto(NAME, Domain.Status.PUBLISHED, null, "dept"), client.restClient(), "metalake"));DomainUpdatesRequest request =new DomainUpdatesRequest(Arrays.asList(@@ -154,7 +149,7 @@ public class TestDomainOperations extends TestBase {@Testpublic void testSnapshotMutations() throws Exception {Domain original = domain();- DomainDTO published = dto(NAME, Domain.Status.PUBLISHED, null, TagValue.noValue("dept"));+ DomainDTO published = dto(NAME, Domain.Status.PUBLISHED, null, "dept");buildMockResource(Method.PATCH,PATH,@@ -191,12 +186,10 @@ public class TestDomainOperations extends TestBase {buildMockResource(Method.PUT,PATH + "/backingTag",- new DomainBackingTagSetRequest(new DomainBackingTagDTO("new/tag", "value")),- new DomainResponse(dto(NAME, Domain.Status.DRAFT, null, TagValue.of("new/tag", "value"))),+ new DomainBackingTagSetRequest(new DomainBackingTagDTO("new/tag")),+ new DomainResponse(dto(NAME, Domain.Status.DRAFT, null, "new/tag")),200);- Assertions.assertEquals(- TagValue.of("new/tag", "value"),- original.updateBackingTag(TagValue.of("new/tag", "value")).backingTag().get());+ Assertions.assertEquals("new/tag", original.updateBackingTag("new/tag").backingTag().get());buildMockResource(Method.PUT,PATH + "/backingTag",@@ -204,7 +197,11 @@ public class TestDomainOperations extends TestBase {new DomainResponse(dto(NAME, Domain.Status.DRAFT, null, null)),200);Assertions.assertFalse(original.updateBackingTag(null).backingTag().isPresent());- Assertions.assertEquals(TagValue.noValue("dept"), original.backingTag().get());+ Assertions.assertEquals("dept", original.backingTag().get());+ Domain blankBackingTag =+ new GenericDomain(+ dto(NAME, Domain.Status.DRAFT, null, " "), client.restClient(), "metalake");+ Assertions.assertThrows(IllegalArgumentException.class, blankBackingTag::backingTag);Assertions.assertThrows(UnsupportedOperationException.class, () -> original.properties().put("x", "y"));}@@ -217,16 +214,15 @@ public class TestDomainOperations extends TestBase {@Testpublic void testSubdomains() throws Exception {Domain domain = domain();- DomainDTO child = dto("Tax/Asia", Domain.Status.DRAFT, NAME, TagValue.noValue("tax"));+ DomainDTO child = dto("Tax/Asia", Domain.Status.DRAFT, NAME, "tax");buildMockResource(Method.POST,ROOT,new DomainCreateRequest(- "Tax/Asia", null, null, NAME, new DomainCreateRequest.BackingTag("tax", null, true)),+ "Tax/Asia", null, null, NAME, new DomainCreateRequest.BackingTag("tax", true)),new DomainResponse(child),200);- assertSnapshot(- domain.createSubdomain("Tax/Asia", null, null, TagValue.noValue("tax"), true), child);+ assertSnapshot(domain.createSubdomain("Tax/Asia", null, null, "tax", true), child);buildMockResource(Method.GET,PATH + "/subdomains",@@ -429,7 +425,7 @@ public class TestDomainOperations extends TestBase {409);Assertions.assertThrows(type.asSubclass(RuntimeException.class),- () -> metalake.createDomain(NAME, null, null, TagValue.noValue("dept"), true));+ () -> metalake.createDomain(NAME, null, null, "dept", true));}buildMockResource(Method.PUT,@@ -437,8 +433,7 @@ public class TestDomainOperations extends TestBase {null,ErrorResponse.notFound("NoSuchTagException", "missing"),404);- Assertions.assertThrows(- NoSuchTagException.class, () -> domain().updateBackingTag(TagValue.noValue("missing")));+ Assertions.assertThrows(NoSuchTagException.class, () -> domain().updateBackingTag("missing"));buildMockResource(Method.PUT, PATH + "/parent", null, ErrorResponse.illegalArguments("invalid parent"), 400);Assertions.assertThrows(@@ -482,8 +477,7 @@ public class TestDomainOperations extends TestBase {Assertions.assertThrows(IllegalArgumentException.class, () -> metalake.createDomain(NAME, null, null, null, false));Assertions.assertThrows(- IllegalArgumentException.class,- () -> metalake.createDomain(NAME, null, null, TagValue.of("tag", "value"), true));+ IllegalArgumentException.class, () -> metalake.createDomain(NAME, null, null, " ", true));Assertions.assertThrows(IllegalArgumentException.class,() -> domain().createSubdomain("child", null, null, null, true));@@ -497,13 +491,11 @@ public class TestDomainOperations extends TestBase {private static Domain domain() {return new GenericDomain(- dto(NAME, Domain.Status.DRAFT, null, TagValue.noValue("dept")),- client.restClient(),- "metalake");+ dto(NAME, Domain.Status.DRAFT, null, "dept"), client.restClient(), "metalake");}private static DomainDTO dto(- String name, Domain.Status status, String parent, TagValue backingTag) {+ String name, Domain.Status status, String parent, String backingTag) {return new DomainDTO(name,"comment",@@ -522,7 +514,7 @@ public class TestDomainOperations extends TestBase {Assertions.assertEquals(expected.getStatus(), actual.status());Assertions.assertEquals(expected.getParent(), actual.parent().orElse(null));Assertions.assertEquals(- expected.getBackingTag() == null ? null : expected.getBackingTag().tagValue(),+ expected.getBackingTag() == null ? null : expected.getBackingTag().getName(),actual.backingTag().orElse(null));Assertions.assertEquals(expected.getAudit(), actual.auditInfo());Assertions.assertEquals(0, actual.relations().length);diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportsDomains.java b/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportsDomains.javaindex e48f1744f8..ab80d588fe 100644--- a/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportsDomains.java+++ b/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportsDomains.java@@ -42,7 +42,6 @@ import org.apache.gravitino.exceptions.ForbiddenException;import org.apache.gravitino.exceptions.NoSuchMetadataObjectException;import org.apache.gravitino.rest.RESTUtils;import org.apache.gravitino.semantic.SemanticModel;-import org.apache.gravitino.tag.TagValue;import org.apache.hc.core5.http.Method;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;@@ -101,7 +100,7 @@ public class TestSupportsDomains extends TestBase {Collections.emptyMap(),Domain.Status.PUBLISHED,null,- TagValue.of("dept", "finance"),+ "dept",AuditDTO.builder().withCreator("test").withCreateTime(Instant.parse("2026-01-01T00:00:00Z"))@@ -127,7 +126,7 @@ public class TestSupportsDomains extends TestBase {200);Domain domain = operations[i].listDomainsInfo()[0];Assertions.assertEquals(dto.getName(), domain.name());- Assertions.assertEquals(TagValue.of("dept", "finance"), domain.backingTag().get());+ Assertions.assertEquals("dept", domain.backingTag().get());Assertions.assertArrayEquals(relations, domain.relations());domain.relations()[0] = null;Assertions.assertArrayEquals(relations, domain.relations());diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainAuthorizationIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainAuthorizationIT.javaindex 6b579a0ecf..af74144234 100644--- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainAuthorizationIT.java+++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainAuthorizationIT.java@@ -51,7 +51,6 @@ import org.apache.gravitino.exceptions.NoSuchTagException;import org.apache.gravitino.rel.Column;import org.apache.gravitino.rel.Table;import org.apache.gravitino.rel.types.Types;-import org.apache.gravitino.tag.TagValue;import org.junit.jupiter.api.Test;/** SDK tests with simple authentication, real owners, role grants, denies and Casbin. */@@ -64,10 +63,8 @@ public class DomainAuthorizationIT extends DomainIT {@Testvoid testVisibilityInheritedPermissionsAndDenyPrecedence() {- Domain parent =- metalake.createDomain("Parent_auth_scope", null, null, TagValue.noValue("parent"), true);- Domain child =- parent.createSubdomain("Child_auth_scope", null, null, TagValue.noValue("child"), true);+ Domain parent = metalake.createDomain("Parent_auth_scope", null, null, "parent", true);+ Domain child = parent.createSubdomain("Child_auth_scope", null, null, "child", true);for (String user : List.of("reader", "manager", "outsider", "owner", "lake_manager")) {metalake.addUser(user);}@@ -139,39 +136,33 @@ public class DomainAuthorizationIT extends DomainIT {GravitinoMetalake creator = creatorClient.loadMetalake(metalake.name());assertThrows(ForbiddenException.class,- () -> creator.createDomain("denied", null, null, TagValue.noValue("new tag"), true));+ () -> creator.createDomain("denied", null, null, "new tag", true));// Creating a backing tag needs CREATE_TAG in addition to domain management.grant("creator",List.of(SecurableObjects.ofMetalake(metalake.name(), List.of(Privileges.CreateTag.allow()))));- Domain created =- creator.createDomain("created", null, null, TagValue.noValue("owned tag"), true);+ Domain created = creator.createDomain("created", null, null, "owned tag", true);// Domain management does not grant ownership of an unrelated tag.metalake.createTag("foreign tag", null, Collections.emptyMap());+ assertThrows(ForbiddenException.class, () -> created.updateBackingTag("foreign tag"));assertThrows(ForbiddenException.class,- () -> created.updateBackingTag(TagValue.noValue("foreign tag")));- assertThrows(- ForbiddenException.class,- () ->- creator.createDomain("foreign", null, null, TagValue.noValue("foreign tag"), false));+ () -> creator.createDomain("foreign", null, null, "foreign tag", false));metalake.setOwner(MetadataObjects.of(null, "foreign tag", MetadataObject.Type.TAG),"creator",Owner.Type.USER);- Domain bound =- creator.createDomain("bound", null, null, TagValue.noValue("foreign tag"), false);- assertEquals(TagValue.noValue("foreign tag"), bound.backingTag().orElseThrow());+ Domain bound = creator.createDomain("bound", null, null, "foreign tag", false);+ assertEquals("foreign tag", bound.backingTag().orElseThrow());assertTrue(bound.updateBackingTag(null).backingTag().isEmpty());- created.updateBackingTag(TagValue.noValue("foreign tag"));+ created.updateBackingTag("foreign tag");assertThrows(BackingTagAlreadyBoundException.class,- () ->- creator.createDomain("conflict", null, null, TagValue.noValue("foreign tag"), false));+ () -> creator.createDomain("conflict", null, null, "foreign tag", false));}}@@ -187,10 +178,8 @@ public class DomainAuthorizationIT extends DomainIT {catalog.asTableCatalog().createTable(NameIdentifier.of("schema", "hidden"), columns, "", Collections.emptyMap());- Domain parent =- metalake.createDomain("access_parent", null, null, TagValue.noValue("parent tag"), true);- Domain child =- parent.createSubdomain("access_child", null, null, TagValue.noValue("child tag"), true);+ Domain parent = metalake.createDomain("access_parent", null, null, "parent tag", true);+ Domain child = parent.createSubdomain("access_child", null, null, "child tag", true);parent.publish();catalog.asSchemas()@@ -288,14 +277,10 @@ public class DomainAuthorizationIT extends DomainIT {@Testvoid testMoveReevaluatesParentGrantsAndMetalakeOwnership() {- Domain first =- metalake.createDomain("first", null, null, TagValue.noValue("first tag"), true).publish();- Domain second =- metalake.createDomain("second", null, null, TagValue.noValue("second tag"), true).publish();+ Domain first = metalake.createDomain("first", null, null, "first tag", true).publish();+ Domain second = metalake.createDomain("second", null, null, "second tag", true).publish();Domain child =- first- .createSubdomain("moving_child_name", null, null, TagValue.noValue("moving tag"), true)- .publish();+ first.createSubdomain("moving_child_name", null, null, "moving tag", true).publish();metalake.addUser("moving_manager");metalake.addUser("lake_owner");grant("moving_manager", List.of(scope(first.name(), Privileges.ManageDomain.allow())));@@ -335,23 +320,14 @@ public class DomainAuthorizationIT extends DomainIT {@Testvoid testWriteEndpointsRejectReadersAndExplicitManagementDenies() {Domain parent =- metalake- .createDomain("matrix-parent", null, null, TagValue.noValue("matrix-parent-tag"), true)- .publish();+ metalake.createDomain("matrix-parent", null, null, "matrix-parent-tag", true).publish();Domain child =- parent- .createSubdomain("matrix-child", null, null, TagValue.noValue("matrix-child-tag"), true)- .publish();+ parent.createSubdomain("matrix-child", null, null, "matrix-child-tag", true).publish();Domain target =- metalake- .createDomain("matrix-target", null, null, TagValue.noValue("matrix-target-tag"), true)- .publish();+ metalake.createDomain("matrix-target", null, null, "matrix-target-tag", true).publish();Domain creationParent =- metalake- .createDomain(- "creation-parent", null, null, TagValue.noValue("creation-parent-tag"), true)- .publish();+ metalake.createDomain("creation-parent", null, null, "creation-parent-tag", true).publish();for (String user : List.of("matrix_reader", "matrix_denied")) {metalake.addUser(user);@@ -395,15 +371,12 @@ public class DomainAuthorizationIT extends DomainIT {() ->reader.getDomain(creationParent.name())- .createSubdomain(- "denied-subdomain", null, null, TagValue.noValue("denied-tag"), true),+ .createSubdomain("denied-subdomain", null, null, "denied-tag", true),user);if (user.equals("matrix_reader")) {assertThrows(ForbiddenException.class,- () ->- reader.createDomain(- "denied-domain", null, null, TagValue.noValue("denied-create-tag"), true));+ () -> reader.createDomain("denied-domain", null, null, "denied-create-tag", true));}}@@ -427,28 +400,15 @@ public class DomainAuthorizationIT extends DomainIT {@Testvoid testNonOwnerManagerCanUseWriteEndpoints() {Domain parent =- metalake- .createDomain(- "allowed-parent", null, null, TagValue.noValue("allowed-parent-tag"), true)- .publish();+ metalake.createDomain("allowed-parent", null, null, "allowed-parent-tag", true).publish();Domain target =- metalake- .createDomain(- "allowed-target", null, null, TagValue.noValue("allowed-target-tag"), true)- .publish();+ metalake.createDomain("allowed-target", null, null, "allowed-target-tag", true).publish();Domain child =- parent- .createSubdomain(- "allowed-child", null, null, TagValue.noValue("allowed-child-tag"), true)- .publish();+ parent.createSubdomain("allowed-child", null, null, "allowed-child-tag", true).publish();Domain creationParent =metalake.createDomain(- "allowed-creation-parent",- null,- null,- TagValue.noValue("allowed-creation-parent-tag"),- true)+ "allowed-creation-parent", null, null, "allowed-creation-parent-tag", true).publish();metalake.addUser("allowed_manager");grant(@@ -475,22 +435,16 @@ public class DomainAuthorizationIT extends DomainIT {assertEquals(target.name(), managed.attachToParent(target.name()).parent().orElseThrow());assertTrue(managed.detachFromParent().parent().isEmpty());assertEquals(- TagValue.noValue("manager-binding-tag"),- managed- .updateBackingTag(TagValue.noValue("manager-binding-tag"))- .backingTag()- .orElseThrow());+ "manager-binding-tag",+ managed.updateBackingTag("manager-binding-tag").backingTag().orElseThrow());assertTrue(managed.updateBackingTag(null).backingTag().isEmpty());// Legal creation requests also succeed when both management and tag creation are allowed.- Domain created =- manager.createDomain(- "denied-domain", null, null, TagValue.noValue("denied-create-tag"), true);+ Domain created = manager.createDomain("denied-domain", null, null, "denied-create-tag", true);Domain subdomain =manager.getDomain(creationParent.name())- .createSubdomain(- "denied-subdomain", null, null, TagValue.noValue("denied-tag"), true);+ .createSubdomain("denied-subdomain", null, null, "denied-tag", true);assertEquals(creationParent.name(), subdomain.parent().orElseThrow());assertEquals(created.name(), manager.getDomain(created.name()).name());assertTrue(manager.deleteDomain(child.name()));diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainIT.javaindex bde5e560d1..78c4344959 100644--- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainIT.java+++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/DomainIT.java@@ -199,15 +199,13 @@ public class DomainIT extends BaseIT {metalake.alterDomain(name, DomainChange.removeProperty("key"), DomainChange.rename("Renamed_US_East"));assertTrue(changed.properties().isEmpty());- assertEquals(- TagValue.noValue(name.replace(".", "_") + " tag"), changed.backingTag().orElseThrow());+ assertEquals(name.replace(".", "_") + " tag", changed.backingTag().orElseThrow());assertNull(metalake.alterDomain(changed.name(), DomainChange.updateComment(null)).comment());assertEquals("new", changed.comment());assertThrows(NoSuchDomainException.class, draft::publish);// An old snapshot addresses the replacement domain by name, not the original entity ID.- Domain replacement =- metalake.createDomain(name, null, null, TagValue.noValue("replacement tag"), true);+ Domain replacement = metalake.createDomain(name, null, null, "replacement tag", true);assertEquals(Domain.Status.PUBLISHED, draft.publish().status());assertEquals(Domain.Status.DRAFT, replacement.status());@@ -220,8 +218,7 @@ public class DomainIT extends BaseIT {void testHierarchyAndBackingTagChanges() {Domain parent = create("Parent_with_spaces");Domain other = create("Other_parent_name");- Domain child =- parent.createSubdomain("Tax_EU_child", null, null, TagValue.noValue("child tag"), true);+ Domain child = parent.createSubdomain("Tax_EU_child", null, null, "child tag", true);assertEquals(parent.name(), child.parent().orElseThrow());assertArrayEquals(new String[] {child.name()}, parent.listSubdomains());assertEquals(child.name(), parent.listSubdomainsInfo()[0].name());@@ -247,11 +244,9 @@ public class DomainIT extends BaseIT {// Removing a binding does not delete the tag or mutate the original snapshot.metalake.createTag("new backing", null, Collections.emptyMap());- assertEquals(- TagValue.noValue("new backing"),- child.updateBackingTag(TagValue.noValue("new backing")).backingTag().orElseThrow());+ assertEquals("new backing", child.updateBackingTag("new backing").backingTag().orElseThrow());assertTrue(child.updateBackingTag(null).backingTag().isEmpty());- assertEquals(TagValue.noValue("child tag"), child.backingTag().orElseThrow());+ assertEquals("child tag", child.backingTag().orElseThrow());assertNotNull(metalake.getTag("child tag"));assertTrue(metalake.deleteDomain(parent.name()));}@@ -261,7 +256,7 @@ public class DomainIT extends BaseIT {Domain domain = create("errors");assertThrows(DomainAlreadyExistsException.class,- () -> metalake.createDomain(domain.name(), null, null, TagValue.noValue("another"), true));+ () -> metalake.createDomain(domain.name(), null, null, "another", true));assertThrows(BackingTagAlreadyBoundException.class,() ->@@ -354,35 +349,30 @@ public class DomainIT extends BaseIT {.asModelCatalog().registerModel(NameIdentifier.of("schema", "model"), "", Collections.emptyMap());- // The schema supplies Finance membership; the nearest table assignment overrides it for Risk.+ // The schema supplies Finance membership; values on the assignments are ignored. Different tags+ // accumulate, so the hidden table is in both Finance and Risk.metalake.createTag("department",null,Collections.emptyMap(),TagValueConstraint.ofAllowedValues("finance", "risk"));- Domain finance =- metalake.createDomain(- "Finance_US_East", null, null, TagValue.of("department", "finance"), false);- Domain risk =- metalake.createDomain("Risk_EU", null, null, TagValue.of("department", "risk"), false);- Domain child =- finance.createSubdomain(- "Trading_US_with_spaces", null, null, TagValue.noValue("trading"), true);+ metalake.createTag("risk", null, Collections.emptyMap());+ Domain finance = metalake.createDomain("Finance_US_East", null, null, "department", false);+ Domain risk = metalake.createDomain("Risk_EU", null, null, "risk", false);+ Domain child = finance.createSubdomain("Trading_US_with_spaces", null, null, "trading", true);catalog.asSchemas().loadSchema("schema")- .supportsTags()- .associateTags(new TagValue[] {TagValue.of("department", "finance")}, new TagValue[0]);- table.supportsTags().associateTags(new String[] {"trading"}, new String[0]);- hidden.supportsTags().associateTags(new TagValue[] {TagValue.of("department", "risk")}, new TagValue[0]);+ table.supportsTags().associateTags(new String[] {"trading"}, new String[0]);+ hidden.supportsTags().associateTags(new String[] {"risk"}, new String[0]);fileset.supportsTags().associateTags(new TagValue[] {TagValue.of("department", "finance")}, new TagValue[0]);model.supportsTags()- .associateTags(new TagValue[] {TagValue.of("department", "finance")}, new TagValue[0]);+ .associateTags(new TagValue[] {TagValue.of("department", "risk")}, new TagValue[0]);// An object can be inherited from Finance and reached through Trading at the same time.Map<String, DomainMember> members =@@ -393,6 +383,7 @@ public class DomainIT extends BaseIT {"ice.schema.orders","ice.schema.orders_view","ice.schema.business",+ "ice.schema.hidden","files.schema.data","models.schema.model"),members.keySet());@@ -448,7 +439,7 @@ public class DomainIT extends BaseIT {.build()).length);assertEquals(- 5,+ 6,finance.listMembers(DomainMemberFilter.builder().withExpand(true)@@ -488,110 +479,50 @@ public class DomainIT extends BaseIT {}@Test- void testNearestTagAssignmentAndValueMatching() {+ void testMembershipIgnoresAssignmentValues() {Catalog catalog = createRelationalCatalog();Table table = createTable(catalog);+ // An existing tag with an allowed-values list backs a domain without a value.metalake.createTag("department",null,Collections.emptyMap(),- TagValueConstraint.ofAllowedValues("finance", "risk", "Finance"));- Domain finance =- metalake.createDomain("Finance", null, null, TagValue.of("department", "finance"), false);- Domain risk =- metalake.createDomain("Risk", null, null, TagValue.of("department", "risk"), false);- Domain caseSensitive =- metalake.createDomain(- "Capitalized", null, null, TagValue.of("department", "Finance"), false);+ TagValueConstraint.ofAllowedValues("finance", "risk"));+ Domain finance = metalake.createDomain("Finance", null, null, "department", false);+ assertEquals("department", metalake.getDomain(finance.name()).backingTag().orElseThrow());+ // A tag backs at most one domain, whether bound at creation or later.assertThrows(- IllegalArgumentException.class,- () -> finance.updateBackingTag(TagValue.of("department", "unknown")));- assertEquals(- TagValue.of("department", "finance"),- metalake.getDomain(finance.name()).backingTag().orElseThrow());+ BackingTagAlreadyBoundException.class,+ () -> metalake.createDomain("Risk", null, null, "department", false));+ Domain risk = create("Risk");+ assertThrows(BackingTagAlreadyBoundException.class, () -> risk.updateBackingTag("department"));- // A catalog assignment is inherited until a nearer schema assignment masks the same tag.+ // Any value on an inherited or direct assignment matches.catalog.supportsTags()- .associateTags(new TagValue[] {TagValue.of("department", "finance")}, new TagValue[0]);+ .associateTags(new TagValue[] {TagValue.of("department", "risk")}, new TagValue[0]);assertTableRelations(finance,table,DomainRelation.inherited(MetadataObjects.parse("ice", MetadataObject.Type.CATALOG)));- assertTableRelations(caseSensitive, table);- catalog- .asSchemas()- .loadSchema("schema")- .supportsTags()- .associateTags(new TagValue[] {TagValue.of("department", "risk")}, new TagValue[0]);- assertTableRelations(finance, table);- assertTableRelations(- risk,- table,- DomainRelation.inherited(MetadataObjects.parse("ice.schema", MetadataObject.Type.SCHEMA)));-- // Multiple direct values match independently and case-sensitively; lower assignments stay- // masked.table.supportsTags()- .associateTags(- new TagValue[] {- TagValue.of("department", "finance"), TagValue.of("department", "Finance")- },- new TagValue[0]);+ .associateTags(new TagValue[] {TagValue.of("department", "finance")}, new TagValue[0]);assertTableRelations(finance, table, DomainRelation.direct());- assertTableRelations(caseSensitive, table, DomainRelation.direct());- assertTableRelations(risk, table);- table- .supportsTags()- .associateTags(new TagValue[0], new TagValue[] {TagValue.of("department", "finance")});- assertTableRelations(finance, table);- assertTableRelations(caseSensitive, table, DomainRelation.direct());- assertTableRelations(risk, table);- // Removing the nearest assignment reveals schema, then catalog, then no membership.+ // Removing the direct assignment reveals the inherited one, then no membership.table.supportsTags()- .associateTags(new TagValue[0], new TagValue[] {TagValue.of("department", "Finance")});- assertTableRelations(- risk,- table,- DomainRelation.inherited(MetadataObjects.parse("ice.schema", MetadataObject.Type.SCHEMA)));- catalog- .asSchemas()- .loadSchema("schema")- .supportsTags()- .associateTags(new TagValue[0], new TagValue[] {TagValue.of("department", "risk")});+ .associateTags(new TagValue[0], new TagValue[] {TagValue.of("department", "finance")});assertTableRelations(finance,table,DomainRelation.inherited(MetadataObjects.parse("ice", MetadataObject.Type.CATALOG)));catalog.supportsTags()- .associateTags(new TagValue[0], new TagValue[] {TagValue.of("department", "finance")});+ .associateTags(new TagValue[0], new TagValue[] {TagValue.of("department", "risk")});assertTableRelations(finance, table);- assertTableRelations(risk, table);- assertTableRelations(caseSensitive, table);-- // A valueless backing binding matches both valued and valueless effective assignments.- metalake.createTag("any-value", null, Collections.emptyMap());- Domain any = metalake.createDomain("Any", null, null, TagValue.noValue("any-value"), false);- table- .supportsTags()- .associateTags(new TagValue[] {TagValue.of("any-value", "arbitrary")}, new TagValue[0]);- assertTableRelations(any, table, DomainRelation.direct());- table- .supportsTags()- .associateTags(- new TagValue[] {TagValue.noValue("any-value")},- new TagValue[] {TagValue.of("any-value", "arbitrary")});- assertTableRelations(any, table, DomainRelation.direct());- assertThrows(- BackingTagAlreadyBoundException.class,- () ->- metalake.createDomain(- "Mixed", null, null, TagValue.of("any-value", "arbitrary"), false));}@Test@@ -599,10 +530,8 @@ public class DomainIT extends BaseIT {Catalog catalog = createRelationalCatalog();Table table = createTable(catalog);Domain parent = create("Parent");- Domain first =- parent.createSubdomain("First_child_A", null, null, TagValue.noValue("first-tag"), true);- Domain second =- parent.createSubdomain("Second_child_B", null, null, TagValue.noValue("second-tag"), true);+ Domain first = parent.createSubdomain("First_child_A", null, null, "first-tag", true);+ Domain second = parent.createSubdomain("Second_child_B", null, null, "second-tag", true);catalog.supportsTags().associateTags(new String[] {"first-tag"}, new String[0]);catalog.asSchemas()@@ -611,7 +540,7 @@ public class DomainIT extends BaseIT {.associateTags(new String[] {"second-tag"}, new String[0]);table.supportsTags()- .associateTags(new String[] {parent.backingTag().orElseThrow().name()}, new String[0]);+ .associateTags(new String[] {parent.backingTag().orElseThrow()}, new String[0]);// The member appears once but retains direct membership and both independent roll-up paths.assertTableRelations(@@ -656,7 +585,7 @@ public class DomainIT extends BaseIT {.length);table.supportsTags()- .associateTags(new String[0], new String[] {parent.backingTag().orElseThrow().name()});+ .associateTags(new String[0], new String[] {parent.backingTag().orElseThrow()});assertTableRelations(parent,table,@@ -672,8 +601,7 @@ public class DomainIT extends BaseIT {// Renaming a tag preserves its identity; deleting and recreating its name must not rebind it.metalake.alterTag("first-tag", TagChange.rename("renamed-first-tag"));- assertEquals(- "renamed-first-tag", metalake.getDomain(first.name()).backingTag().orElseThrow().name());+ assertEquals("renamed-first-tag", metalake.getDomain(first.name()).backingTag().orElseThrow());assertTableRelations(parent, table, DomainRelation.viaSubdomain(first.name()));metalake.deleteTag("renamed-first-tag");assertTrue(metalake.getDomain(first.name()).backingTag().isEmpty());@@ -682,7 +610,7 @@ public class DomainIT extends BaseIT {catalog.supportsTags().associateTags(new String[] {"renamed-first-tag"}, new String[0]);assertTableRelations(first, table);assertTableRelations(parent, table);- first.updateBackingTag(TagValue.noValue("renamed-first-tag"));+ first.updateBackingTag("renamed-first-tag");assertTableRelations(first,table,@@ -696,7 +624,7 @@ public class DomainIT extends BaseIT {void testInvalidHierarchyAtomicCreationAndIdempotence() {Domain parent = create("Parent");Domain other = create("Other");- Domain child = parent.createSubdomain("Child", null, null, TagValue.noValue("child-tag"), true);+ Domain child = parent.createSubdomain("Child", null, null, "child-tag", true);metalake.createTag("existing-valued-tag",@@ -705,13 +633,9 @@ public class DomainIT extends BaseIT {TagValueConstraint.ofAllowedValues("finance"));Domain bound =parent.createSubdomain(- "Bound",- "existing tag",- Map.of("key", "value"),- TagValue.of("existing-valued-tag", "finance"),- false);+ "Bound", "existing tag", Map.of("key", "value"), "existing-valued-tag", false);assertEquals(parent.name(), bound.parent().orElseThrow());- assertEquals(TagValue.of("existing-valued-tag", "finance"), bound.backingTag().orElseThrow());+ assertEquals("existing-valued-tag", bound.backingTag().orElseThrow());assertEquals(Map.of("key", "value"), bound.properties());assertThrows(DomainAlreadyExistsException.class,@@ -721,15 +645,12 @@ public class DomainIT extends BaseIT {// Hierarchy validation must leave neither a new domain nor its requested backing tag behind.assertThrows(IllegalArgumentException.class,- () ->- child.createSubdomain(- "Grandchild", null, null, TagValue.noValue("grandchild-tag"), true));+ () -> child.createSubdomain("Grandchild", null, null, "grandchild-tag", true));assertThrows(NoSuchDomainException.class, () -> metalake.getDomain("Grandchild"));assertThrows(NoSuchTagException.class, () -> metalake.getTag("grandchild-tag"));assertThrows(DomainAlreadyExistsException.class,- () ->- metalake.createDomain(parent.name(), null, null, TagValue.noValue("unused-tag"), true));+ () -> metalake.createDomain(parent.name(), null, null, "unused-tag", true));assertThrows(NoSuchTagException.class, () -> metalake.getTag("unused-tag"));assertThrows(IllegalArgumentException.class, () -> child.attachToParent(child.name()));assertThrows(IllegalArgumentException.class, () -> other.attachToParent(child.name()));@@ -769,80 +690,57 @@ public class DomainIT extends BaseIT {() -> removed.listMembers(DomainMemberFilter.builder().withExpand(true).build()));assertThrows(NoSuchDomainException.class,- () -> removed.createSubdomain("orphan", null, null, TagValue.noValue("orphan-tag"), true));+ () -> removed.createSubdomain("orphan", null, null, "orphan-tag", true));assertThrows(NoSuchTagException.class, () -> metalake.getTag("orphan-tag"));assertFalse(metalake.deleteDomain(removed.name()));Domain domain = create("binding-errors");assertThrows(NoSuchDomainException.class, () -> domain.attachToParent("missing-parent"));assertTrue(metalake.getDomain(domain.name()).parent().isEmpty());- assertThrows(- NoSuchTagException.class, () -> domain.updateBackingTag(TagValue.noValue("absent-tag")));+ assertThrows(NoSuchTagException.class, () -> domain.updateBackingTag("absent-tag"));assertEquals(domain.backingTag(), metalake.getDomain(domain.name()).backingTag());// Failed creation must neither adopt an existing tag nor create a partial domain.assertThrows(NoSuchTagException.class,- () ->- metalake.createDomain(- "missing-binding", null, null, TagValue.noValue("absent-tag"), false));+ () -> metalake.createDomain("missing-binding", null, null, "absent-tag", false));assertThrows(TagAlreadyExistsException.class,() ->metalake.createDomain("existing-binding", null, null, domain.backingTag().orElseThrow(), true));- assertThrows(- IllegalArgumentException.class,- () ->- metalake.createDomain(- "valued-new-tag", null, null, TagValue.of("invalid-new-tag", "value"), true));- for (String name : List.of("missing-binding", "existing-binding", "valued-new-tag", "orphan")) {+ for (String name : List.of("missing-binding", "existing-binding", "orphan")) {assertThrows(NoSuchDomainException.class, () -> metalake.getDomain(name));}- assertThrows(NoSuchTagException.class, () -> metalake.getTag("invalid-new-tag"));- assertNotNull(metalake.getTag(domain.backingTag().orElseThrow().name()));+ assertNotNull(metalake.getTag(domain.backingTag().orElseThrow()));}@Test- void testBackingTagValueLengthBoundaries() {+ void testUnicodeAssignmentValuesAreIgnored() {Table table = createTable(createRelationalCatalog());String[] values = {"x".repeat(256), "😀".repeat(128)};for (int index = 0; index < values.length; index++) {String tagName = "unicode-boundary-" + index;metalake.createTag(tagName, null, Collections.emptyMap());String name = "F".repeat(63) + index;- TagValue binding = TagValue.of(tagName, values[index]);Domain domain =metalake.createDomain(- name, "Unicode comment 中文😀", Map.of("region", "亚洲😀"), binding, false);+ name, "Unicode comment 中文😀", Map.of("region", "亚洲😀"), tagName, false);assertEquals(name, metalake.getDomain(name).name());- assertEquals(binding, metalake.getDomain(name).backingTag().orElseThrow());+ assertEquals(tagName, metalake.getDomain(name).backingTag().orElseThrow());assertEquals("亚洲😀", metalake.getDomain(name).properties().get("region"));- // Boundary values must survive JSON, storage and effective-tag membership resolution.- table.supportsTags().associateTags(new TagValue[] {binding}, new TagValue[0]);+ // A boundary value on the assignment does not affect membership.+ table+ .supportsTags()+ .associateTags(new TagValue[] {TagValue.of(tagName, values[index])}, new TagValue[0]);assertTableRelations(domain, table, DomainRelation.direct());String renamed = "Tax-" + index;Domain changed = metalake.alterDomain(name, DomainChange.rename(renamed));assertEquals(renamed, metalake.getDomain(renamed).name());- assertEquals(binding, changed.backingTag().orElseThrow());+ assertEquals(tagName, changed.backingTag().orElseThrow());assertTableRelations(changed, table, DomainRelation.direct());assertThrows(NoSuchDomainException.class, () -> metalake.getDomain(name));-- // Both ASCII and supplementary characters use the same 256 UTF-16-unit limit.- String invalid = values[index] + "x";- assertThrows(- IllegalArgumentException.class,- () -> changed.updateBackingTag(TagValue.of(tagName, invalid)));- assertEquals(binding, metalake.getDomain(renamed).backingTag().orElseThrow());- String rejectedName = "rejected-boundary-" + index;- assertThrows(- IllegalArgumentException.class,- () ->- metalake.createDomain(- rejectedName, null, null, TagValue.of(tagName, invalid), false));- assertThrows(NoSuchDomainException.class, () -> metalake.getDomain(rejectedName));- assertTableRelations(changed, table, DomainRelation.direct());}}@@ -851,11 +749,7 @@ public class DomainIT extends BaseIT {Table table = createTable(createRelationalCatalog());Domain created =metalake.createDomain(- "value-contract",- "original",- Map.of("key", "value"),- TagValue.noValue("value-contract-tag"),- true);+ "value-contract", "original", Map.of("key", "value"), "value-contract-tag", true);Domain loaded = metalake.getDomain(created.name());Domain listed = metalake.listDomainsInfo()[0];assertEquals(created, loaded);@@ -943,7 +837,6 @@ public class DomainIT extends BaseIT {}private Domain create(String name) {- return metalake.createDomain(- name, null, null, TagValue.noValue(name.replace(".", "_") + " tag"), true);+ return metalake.createDomain(name, null, null, name.replace(".", "_") + " tag", true);}}diff --git a/clients/client-python/gravitino/api/domain/domain.py b/clients/client-python/gravitino/api/domain/domain.pyindex 4e712d4b38..0c3d501378 100644--- a/clients/client-python/gravitino/api/domain/domain.py+++ b/clients/client-python/gravitino/api/domain/domain.py@@ -26,7 +26,6 @@ from gravitino.api.auditable import Auditablefrom gravitino.api.domain.domain_member import DomainMemberfrom gravitino.api.domain.domain_member_filter import DomainMemberFilterfrom gravitino.api.domain.domain_relation import DomainRelation-from gravitino.api.tag.tag_value import TagValueclass Domain(Auditable):@@ -71,8 +70,12 @@ class Domain(Auditable):raise NotImplementedError@abstractmethod- def backing_tag(self) -> Optional[TagValue]:- """Return the backing tag, or None when removed or deleted."""+ def backing_tag(self) -> Optional[str]:+ """Return the backing tag name, or None when removed or deleted.++ Objects that carry the tag, with or without values, are members; any+ value on an assignment is ignored. A tag backs at most one domain.+ """raise NotImplementedError@abstractmethod@@ -106,8 +109,8 @@ class Domain(Auditable):raise NotImplementedError@abstractmethod- def update_backing_tag(self, backing_tag: Optional[TagValue]) -> Domain:- """Bind an existing tag, or remove with None, returning a new snapshot."""+ def update_backing_tag(self, backing_tag: Optional[str]) -> Domain:+ """Bind an existing tag by name, or remove with None, returning a new snapshot."""raise NotImplementedError@abstractmethod@@ -116,10 +119,10 @@ class Domain(Auditable):name: str,comment: Optional[str],properties: Optional[dict[str, str]],- backing_tag: TagValue,+ backing_tag: str,create_backing_tag: bool,) -> Domain:- """Create a draft subdomain with an explicit backing tag."""+ """Create a draft subdomain with an explicit backing tag name."""raise NotImplementedError@abstractmethoddiff --git a/clients/client-python/gravitino/api/domain/domain_operations.py b/clients/client-python/gravitino/api/domain/domain_operations.pyindex ab8d7b542d..fae8894d59 100644--- a/clients/client-python/gravitino/api/domain/domain_operations.py+++ b/clients/client-python/gravitino/api/domain/domain_operations.py@@ -20,7 +20,6 @@ from typing import Optionalfrom gravitino.api.domain.domain import Domainfrom gravitino.api.domain.domain_change import DomainChangeVariant-from gravitino.api.tag.tag_value import TagValueclass DomainOperations(ABC):@@ -51,12 +50,14 @@ class DomainOperations(ABC):name: str,comment: Optional[str],properties: Optional[dict[str, str]],- backing_tag: TagValue,+ backing_tag: str,create_backing_tag: bool,) -> Domain:"""Create a draft top-level domain, explicitly creating or binding its tag.- A new tag cannot have a value. Existing tags are never adopted implicitly.+ A new tag is created without values; an existing tag is bound whatever+ values it allows, and backs at most one domain. Existing tags are never+ adopted implicitly.Domain and new tag creation are atomic. Conflicts raiseDomainAlreadyExistsException, TagAlreadyExistsException orBackingTagAlreadyBoundException; missing tags raise NoSuchTagException.diff --git a/clients/client-python/gravitino/client/generic_domain.py b/clients/client-python/gravitino/client/generic_domain.pyindex a776d19e05..f0b79881b5 100644--- a/clients/client-python/gravitino/client/generic_domain.py+++ b/clients/client-python/gravitino/client/generic_domain.py@@ -22,7 +22,6 @@ from gravitino.api.domain.domain import Domainfrom gravitino.api.domain.domain_member import DomainMemberfrom gravitino.api.domain.domain_member_filter import DomainMemberFilterfrom gravitino.api.domain.domain_relation import DomainRelation-from gravitino.api.tag.tag_value import TagValuefrom gravitino.dto.audit_dto import AuditDTOfrom gravitino.dto.domain_dto import DomainBackingTagDTO, DomainDTOfrom gravitino.dto.requests.domain_create_request import (@@ -96,7 +95,7 @@ class GenericDomain(Domain):def parent(self) -> Optional[str]:return self._domain.parent()- def backing_tag(self) -> Optional[TagValue]:+ def backing_tag(self) -> Optional[str]:return self._domain.backing_tag()def audit_info(self) -> AuditDTO:@@ -142,11 +141,9 @@ class GenericDomain(Domain):))- def update_backing_tag(self, backing_tag: Optional[TagValue]) -> Domain:+ def update_backing_tag(self, backing_tag: Optional[str]) -> Domain:request = DomainBackingTagSetRequest(- DomainBackingTagDTO(backing_tag.name(), backing_tag.value())- if backing_tag is not None- else None+ DomainBackingTagDTO(backing_tag) if backing_tag is not None else None)request.validate()return self._snapshot(@@ -162,7 +159,7 @@ class GenericDomain(Domain):name: str,comment: Optional[str],properties: Optional[dict[str, str]],- backing_tag: TagValue,+ backing_tag: str,create_backing_tag: bool,) -> Domain:Precondition.check_argument(@@ -173,9 +170,7 @@ class GenericDomain(Domain):comment,properties,self.name(),- BackingTagCreate(- backing_tag.name(), backing_tag.value(), create_backing_tag- ),+ BackingTagCreate(backing_tag, create_backing_tag),)request.validate()return self._snapshot(diff --git a/clients/client-python/gravitino/client/gravitino_client.py b/clients/client-python/gravitino/client/gravitino_client.pyindex 849ce8ff5a..dad141dc9f 100644--- a/clients/client-python/gravitino/client/gravitino_client.py+++ b/clients/client-python/gravitino/client/gravitino_client.py@@ -41,7 +41,6 @@ from gravitino.api.secret import SecretBinding, SecretReferencefrom gravitino.api.domain.domain import Domainfrom gravitino.api.domain.domain_change import DomainChangeVariantfrom gravitino.api.domain.domain_operations import DomainOperations-from gravitino.api.tag.tag_value import TagValuefrom gravitino.api.tag.tag_operations import TagOperationsfrom gravitino.auth.auth_data_provider import AuthDataProviderfrom gravitino.client.gravitino_client_base import GravitinoClientBase@@ -939,7 +938,7 @@ class GravitinoClient(name: str,comment: Optional[str],properties: Optional[dict[str, str]],- backing_tag: TagValue,+ backing_tag: str,create_backing_tag: bool,) -> Domain:"""Create a draft top-level domain with an explicit new or existing tag."""diff --git a/clients/client-python/gravitino/client/gravitino_metalake.py b/clients/client-python/gravitino/client/gravitino_metalake.pyindex 00b3557c20..2b8492915b 100644--- a/clients/client-python/gravitino/client/gravitino_metalake.py+++ b/clients/client-python/gravitino/client/gravitino_metalake.py@@ -29,7 +29,6 @@ from gravitino.api.authorization.user import Userfrom gravitino.api.domain.domain import Domainfrom gravitino.api.domain.domain_change import DomainChangeVariantfrom gravitino.api.domain.domain_operations import DomainOperations-from gravitino.api.tag.tag_value import TagValuefrom gravitino.client.generic_domain import GenericDomainfrom gravitino.dto.requests.domain_create_request import (BackingTagCreate,@@ -761,7 +760,7 @@ class GravitinoMetalake(name: str,comment: Optional[str],properties: Optional[dict[str, str]],- backing_tag: TagValue,+ backing_tag: str,create_backing_tag: bool,) -> Domain:"""Create a draft top-level domain with an explicit new or existing tag."""@@ -773,9 +772,7 @@ class GravitinoMetalake(comment,properties,None,- BackingTagCreate(- backing_tag.name(), backing_tag.value(), create_backing_tag- ),+ BackingTagCreate(backing_tag, create_backing_tag),)request.validate()response = self.rest_client.post(diff --git a/clients/client-python/gravitino/dto/domain_dto.py b/clients/client-python/gravitino/dto/domain_dto.pyindex 01efebc1b1..59b5a66d99 100644--- a/clients/client-python/gravitino/dto/domain_dto.py+++ b/clients/client-python/gravitino/dto/domain_dto.py@@ -25,7 +25,6 @@ from gravitino.api.domain.domain_member import DomainMemberfrom gravitino.api.domain.domain_relation import DomainRelationfrom gravitino.api.metadata_object import MetadataObjectfrom gravitino.api.metadata_objects import MetadataObjects-from gravitino.api.tag.tag_value import TagValuefrom gravitino.dto.audit_dto import AuditDTOfrom gravitino.dto.metadata_object_dto import MetadataObjectDTOfrom gravitino.utils.precondition import Precondition@@ -34,13 +33,18 @@ from gravitino.utils.precondition import Precondition@dataclass_json@dataclassclass DomainBackingTagDTO:- """The backing tag on the wire."""+ """The name of the backing tag on the wire."""_name: str = field(metadata=config(field_name="name"))- _value: Optional[str] = field(default=None, metadata=config(field_name="value"))- def tag_value(self) -> TagValue:- return TagValue(self._name, self._value)+ def name(self) -> str:+ return self._name++ def validate(self) -> None:+ Precondition.check_argument(+ isinstance(self._name, str) and self._name.strip() != "",+ "backingTag.name must be a non-blank string",+ )@dataclass_json@@ -122,8 +126,8 @@ class DomainDTO: # pylint: disable=too-many-instance-attributesdef parent(self) -> Optional[str]:return self._parent- def backing_tag(self) -> Optional[TagValue]:- return self._backing_tag.tag_value() if self._backing_tag else None+ def backing_tag(self) -> Optional[str]:+ return self._backing_tag.name() if self._backing_tag else Nonedef audit_info(self) -> AuditDTO:return self._audit@@ -146,3 +150,5 @@ class DomainDTO: # pylint: disable=too-many-instance-attributesPrecondition.check_argument(self._audit is not None, "Domain response must have audit information")+ if self._backing_tag is not None:+ self._backing_tag.validate()diff --git a/clients/client-python/gravitino/dto/requests/domain_create_request.py b/clients/client-python/gravitino/dto/requests/domain_create_request.pyindex 0c10b777d3..408d119c0a 100644--- a/clients/client-python/gravitino/dto/requests/domain_create_request.py+++ b/clients/client-python/gravitino/dto/requests/domain_create_request.py@@ -32,13 +32,6 @@ class BackingTagCreate(DomainBackingTagDTO):_create: bool = field(default=False, metadata=config(field_name="create"))- def validate(self) -> None:- tag = self.tag_value()- Precondition.check_argument(- not self._create or tag.value() is None,- "A new backing tag cannot have a value",- )-@dataclass_json@dataclassdiff --git a/clients/client-python/gravitino/dto/requests/domain_set_request.py b/clients/client-python/gravitino/dto/requests/domain_set_request.pyindex 13ce0c85f0..5ab3ca0860 100644--- a/clients/client-python/gravitino/dto/requests/domain_set_request.py+++ b/clients/client-python/gravitino/dto/requests/domain_set_request.py@@ -64,4 +64,4 @@ class DomainBackingTagSetRequest(RESTRequest):def validate(self) -> None:if self._backing_tag is not None:- self._backing_tag.tag_value()+ self._backing_tag.validate()diff --git a/clients/client-python/tests/integration/domain_api_edges_mixin.py b/clients/client-python/tests/integration/domain_api_edges_mixin.pyindex 851c416df4..51d1404874 100644--- a/clients/client-python/tests/integration/domain_api_edges_mixin.py+++ b/clients/client-python/tests/integration/domain_api_edges_mixin.py@@ -26,10 +26,8 @@ from gravitino.api.domain import (DomainMemberFilter,DomainRelation,)-from gravitino.api.tag import TagValuefrom gravitino.exceptions.base import (ForbiddenException,- IllegalArgumentException,NoSuchDomainException,NoSuchTagException,TagAlreadyExistsException,@@ -44,7 +42,7 @@ class DomainApiEdgesMixin:self.skipTest("Requires an authorization-enabled server")parent = self._domain("matrix-parent").publish()child = parent.create_subdomain(- "matrix-child", None, {}, TagValue("matrix-child-tag"), True+ "matrix-child", None, {}, "matrix-child-tag", True).publish()target = self._domain("matrix-target").publish()@@ -98,13 +96,11 @@ class DomainApiEdgesMixin:),"subdomain": lambda client=reader: client.get_domain(creation_parent.name()- ).create_subdomain(- "denied-subdomain", None, {}, TagValue("denied-tag"), True- ),+ ).create_subdomain("denied-subdomain", None, {}, "denied-tag", True),}if user == "matrix_reader":writes["create"] = lambda client=reader: client.create_domain(- "denied-domain", None, {}, TagValue("denied-create-tag"), True+ "denied-domain", None, {}, "denied-create-tag", True)for endpoint, operation in writes.items():with self.subTest(user=user, endpoint=endpoint):@@ -132,7 +128,7 @@ class DomainApiEdgesMixin:parent = self._domain("allowed-parent").publish()target = self._domain("allowed-target").publish()child = parent.create_subdomain(- "allowed-child", None, {}, TagValue("allowed-child-tag"), True+ "allowed-child", None, {}, "allowed-child-tag", True).publish()creation_parent = self._domain("allowed-creation-parent").publish()manager = self._client("allowed_manager")@@ -167,17 +163,17 @@ class DomainApiEdgesMixin:)self.assertIsNone(managed.detach_from_parent().parent())self.assertEqual(- TagValue("manager-binding-tag"),- managed.update_backing_tag(TagValue("manager-binding-tag")).backing_tag(),+ "manager-binding-tag",+ managed.update_backing_tag("manager-binding-tag").backing_tag(),)self.assertIsNone(managed.update_backing_tag(None).backing_tag())# These legal requests match the denied creation requests with management now allowed.created = manager.create_domain(- "denied-domain", None, {}, TagValue("denied-create-tag"), True+ "denied-domain", None, {}, "denied-create-tag", True)subdomain = manager.get_domain(creation_parent.name()).create_subdomain(- "denied-subdomain", None, {}, TagValue("denied-tag"), True+ "denied-subdomain", None, {}, "denied-tag", True)self.assertEqual(creation_parent.name(), subdomain.parent())self.assertEqual(created.name(), manager.get_domain(created.name()).name())@@ -185,54 +181,44 @@ class DomainApiEdgesMixin:with self.assertRaises(NoSuchDomainException):self.lake.get_domain(child.name())- def test_backing_tag_value_length_boundaries(self):+ def test_unicode_assignment_values_are_ignored(self):_, table = self._relational_table()for index, value in enumerate(("x" * 256, "😀" * 128)):with self.subTest(index=index):tag_name = f"unicode-boundary-{index}"self.lake.create_tag(tag_name, None, {})name = "F" * 63 + str(index)- binding = TagValue(tag_name, value)domain = self.lake.create_domain(- name, "Unicode comment 中文😀", {"region": "亚洲😀"}, binding, False+ name,+ "Unicode comment 中文😀",+ {"region": "亚洲😀"},+ tag_name,+ False,)loaded = self.lake.get_domain(name)self.assertEqual(name, loaded.name())- self.assertEqual(binding, loaded.backing_tag())+ self.assertEqual(tag_name, loaded.backing_tag())self.assertEqual({"region": "亚洲😀"}, loaded.properties())- # Boundary values survive serialization, storage and membership resolution.+ # A boundary value on the assignment does not affect membership.table.supports_tags().assign_tags([{"name": tag_name, "value": value}])direct = {(DomainRelation.Type.DIRECT, None, None)}self._assert_table_relations(domain, table, direct)renamed = f"Tax-{index}"changed = self.lake.alter_domain(name, DomainChange.rename(renamed))self.assertEqual(renamed, self.lake.get_domain(renamed).name())- self.assertEqual(binding, changed.backing_tag())+ self.assertEqual(tag_name, changed.backing_tag())self._assert_table_relations(changed, table, direct)with self.assertRaises(NoSuchDomainException):self.lake.get_domain(name)- # The Python client must enforce Java's UTF-16-unit limit before HTTP.- with self.assertRaises(IllegalArgumentException):- changed.update_backing_tag(TagValue(tag_name, value + "x"))- self.assertEqual(binding, self.lake.get_domain(renamed).backing_tag())- rejected_name = f"rejected-boundary-{index}"- with self.assertRaises(IllegalArgumentException):- self.lake.create_domain(- rejected_name, None, {}, TagValue(tag_name, value + "x"), False- )- with self.assertRaises(NoSuchDomainException):- self.lake.get_domain(rejected_name)- self._assert_table_relations(changed, table, direct)-def test_real_response_value_equality_and_snapshot_protection(self):_, table = self._relational_table()created = self.lake.create_domain("value-contract","original",{"key": "value"},- TagValue("value-contract-tag"),+ "value-contract-tag",True,)loaded = self.lake.get_domain(created.name())@@ -304,7 +290,7 @@ class DomainApiEdgesMixin:"subdomains_info": removed.list_subdomains_info,"members": lambda: removed.list_members(DomainMemberFilter(expand=True)),"create_subdomain": lambda: removed.create_subdomain(- "orphan", None, {}, TagValue("orphan-tag"), True+ "orphan", None, {}, "orphan-tag", True),}for endpoint, operation in operations.items():@@ -321,21 +307,15 @@ class DomainApiEdgesMixin:domain.attach_to_parent("missing-parent")self.assertIsNone(self.lake.get_domain(domain.name()).parent())with self.assertRaises(NoSuchTagException):- domain.update_backing_tag(TagValue("absent-tag"))+ domain.update_backing_tag("absent-tag")self.assertEqual(domain.backing_tag(), self.lake.get_domain(domain.name()).backing_tag())# A rejected creation must not adopt an existing tag or leave an orphan domain.invalid = [- ("missing-binding", TagValue("absent-tag"), False, NoSuchTagException),+ ("missing-binding", "absent-tag", False, NoSuchTagException),("existing-binding", domain.backing_tag(), True, TagAlreadyExistsException),- (- "valued-new-tag",- TagValue("invalid-new-tag", "value"),- True,- IllegalArgumentException,- ),]for name, tag, create_tag, error in invalid:with self.subTest(name=name):@@ -343,6 +323,4 @@ class DomainApiEdgesMixin:self.lake.create_domain(name, None, {}, tag, create_tag)with self.assertRaises(NoSuchDomainException):self.lake.get_domain(name)- with self.assertRaises(NoSuchTagException):- self.lake.get_tag("invalid-new-tag")- self.assertIsNotNone(self.lake.get_tag(domain.backing_tag().name()))+ self.assertIsNotNone(self.lake.get_tag(domain.backing_tag()))diff --git a/clients/client-python/tests/integration/test_domain.py b/clients/client-python/tests/integration/test_domain.pyindex 1e0a95bccb..0e79b97705 100644--- a/clients/client-python/tests/integration/test_domain.py+++ b/clients/client-python/tests/integration/test_domain.py@@ -39,7 +39,6 @@ from gravitino.api.rel.sql_representation import SQLRepresentationfrom gravitino.api.rel.types.types import Typesfrom gravitino.api.semantic.dataset import Datasetfrom gravitino.api.semantic.semantic_model_definition import SemanticModelDefinition-from gravitino.api.tag import TagValuefrom gravitino.api.tag.tag_change import TagChangefrom gravitino.auth.simple_auth_provider import SimpleAuthProviderfrom gravitino.client.metadata_object_domain_operations import (@@ -88,7 +87,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):def _domain(self, name):return self.lake.create_domain(- name, None, {}, TagValue(name.replace(".", "_") + " tag"), True+ name, None, {}, name.replace(".", "_") + " tag", True)def _client(self, user):@@ -198,9 +197,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):self.assertEqual({"key": "value"}, renamed.properties())self.assertIsNone(draft.comment())self.assertEqual({}, draft.properties())- self.assertEqual(- TagValue(name.replace(".", "_") + " tag"), renamed.backing_tag()- )+ self.assertEqual(name.replace(".", "_") + " tag", renamed.backing_tag())self.assertEqual({},self.lake.alter_domain(@@ -218,9 +215,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):# The snapshot keeps its name, so reusing that name redirects future mutations.with self.assertRaises(NoSuchDomainException):draft.publish()- replacement = self.lake.create_domain(- name, None, None, TagValue("replacement"), True- )+ replacement = self.lake.create_domain(name, None, None, "replacement", True)self.assertEqual(Domain.Status.PUBLISHED, draft.publish().status())self.assertEqual(Domain.Status.DRAFT, replacement.status())self.assertTrue(self.lake.delete_domain(name))@@ -229,9 +224,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):def test_hierarchy_and_backing_tag_errors(self):parent = self._domain("Parent_with_spaces")other = self._domain("Other_parent_name")- child = parent.create_subdomain(- "Tax_EU_child", None, None, TagValue("child tag"), True- )+ child = parent.create_subdomain("Tax_EU_child", None, None, "child tag", True)self.assertEqual([child.name()], parent.list_subdomains())self.assertEqual(child.name(), parent.list_subdomains_info()[0].name())@@ -255,25 +248,22 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):self.assertIsNone(child.detach_from_parent().parent())self.assertEqual(parent.name(), child.parent())- # Binding changes preserve tags and reject conflicting assignments.+ # A tag with allowed values can back a domain, and backs at most one domain.self.lake.create_tag("new tag", None, {}, ["finance", "risk"])- self.assertEqual(- TagValue("new tag", "finance"),- child.update_backing_tag(TagValue("new tag", "finance")).backing_tag(),- )- conflict = self.lake.create_domain(- "conflict", None, None, TagValue("new tag", "risk"), False- )+ self.assertEqual("new tag", child.update_backing_tag("new tag").backing_tag())+ with self.assertRaises(BackingTagAlreadyBoundException):+ self.lake.create_domain("conflict", None, None, "new tag", False)+ conflict = self._domain("conflict")with self.assertRaises(BackingTagAlreadyBoundException):- conflict.update_backing_tag(TagValue("new tag", "finance"))+ conflict.update_backing_tag("new tag")with self.assertRaises(NoSuchTagException):- child.update_backing_tag(TagValue("missing"))+ child.update_backing_tag("missing")self.assertIsNone(child.update_backing_tag(None).backing_tag())- self.assertEqual(TagValue("child tag"), child.backing_tag())+ self.assertEqual("child tag", child.backing_tag())with self.assertRaises(TagAlreadyExistsException):- self.lake.create_domain("new", None, {}, TagValue("child tag"), True)+ self.lake.create_domain("new", None, {}, "child tag", True)with self.assertRaises(DomainAlreadyExistsException):- self.lake.create_domain(parent.name(), None, {}, TagValue("unused"), True)+ self.lake.create_domain(parent.name(), None, {}, "unused", True)def _assert_direct_members(self, finance):direct = {@@ -301,29 +291,29 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):[r.type() for r in direct["ice.schema.orders"].relations()],)- def test_members_relations_filters_and_nearest_assignment(self):+ def test_members_relations_and_filters(self):catalog, table, hidden, view, semantic, fileset, model = self._catalogs()self.lake.create_tag("department", None, {}, ["finance", "risk"])+ self.lake.create_tag("risk", None, {})finance = self.lake.create_domain(- "Finance_US_East", None, {}, TagValue("department", "finance"), False- )- risk = self.lake.create_domain(- "Risk_EU", None, {}, TagValue("department", "risk"), False+ "Finance_US_East", None, {}, "department", False)+ risk = self.lake.create_domain("Risk_EU", None, {}, "risk", False)child = finance.create_subdomain(- "Trading_US_with_spaces", None, {}, TagValue("trading"), True+ "Trading_US_with_spaces", None, {}, "trading", True)- # The schema grants Finance membership; the table assignment takes precedence for Risk.+ # The schema grants Finance membership whatever its value; different tags accumulate,+ # so the hidden table is in both Finance and Risk.catalog.as_schemas().load_schema("schema").supports_tags().assign_tags(- [{"name": "department", "value": "finance"}]+ [{"name": "department", "value": "risk"}])table.supports_tags().assign_tags(["trading"])- hidden.supports_tags().assign_tags([{"name": "department", "value": "risk"}])+ hidden.supports_tags().assign_tags(["risk"])fileset.supports_tags().assign_tags([{"name": "department", "value": "finance"}])- model.supports_tags().assign_tags([{"name": "department", "value": "finance"}])+ model.supports_tags().assign_tags([{"name": "department", "value": "risk"}])# The same table has both inherited and subdomain relations, with no precedence.members = {@@ -335,6 +325,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):"ice.schema.orders","ice.schema.orders_view","ice.schema.business",+ "ice.schema.hidden","files.schema.data","models.schema.model",},@@ -385,7 +376,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):],)self.assertEqual(- 5,+ 6,len(finance.list_members(DomainMemberFilter(@@ -444,9 +435,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):if not self.authorization:self.skipTest("Requires an authorization-enabled server")parent = self._domain("Parent_auth_scope")- child = parent.create_subdomain(- "Child_auth_scope", None, {}, TagValue("child"), True- )+ child = parent.create_subdomain("Child_auth_scope", None, {}, "child", True)reader = self._client("reader")manager = self._client("manager")outsider = self._client("outsider")@@ -528,52 +517,48 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):],)with self.assertRaises(ForbiddenException):- creator.create_domain("denied", None, {}, TagValue("new tag"), True)+ creator.create_domain("denied", None, {}, "new tag", True)self._grant("creator",[SecurableObjects.of_metalake(self.name, [Privileges.allow("CREATE_TAG")])],)# Creating a backing tag needs CREATE_TAG in addition to domain management.- created = creator.create_domain(- "created", None, {}, TagValue("owned tag"), True- )+ created = creator.create_domain("created", None, {}, "owned tag", True)# Managing a domain does not confer ownership of another user's tag.self.lake.create_tag("foreign tag", None, {})with self.assertRaises(ForbiddenException):- created.update_backing_tag(TagValue("foreign tag"))+ created.update_backing_tag("foreign tag")with self.assertRaises(ForbiddenException):- creator.create_domain("foreign", None, {}, TagValue("foreign tag"), False)+ creator.create_domain("foreign", None, {}, "foreign tag", False)self.lake.set_owner(MetadataObjects.parse("foreign tag", MetadataObject.Type.TAG),"creator",Owner.Type.USER,)- bound = creator.create_domain("bound", None, {}, TagValue("foreign tag"), False)- self.assertEqual(TagValue("foreign tag"), bound.backing_tag())+ bound = creator.create_domain("bound", None, {}, "foreign tag", False)+ self.assertEqual("foreign tag", bound.backing_tag())self.assertIsNone(bound.update_backing_tag(None).backing_tag())self.assertEqual(- TagValue("foreign tag"),- created.update_backing_tag(TagValue("foreign tag")).backing_tag(),+ "foreign tag",+ created.update_backing_tag("foreign tag").backing_tag(),)with self.assertRaises(BackingTagAlreadyBoundException):- creator.create_domain("conflict", None, {}, TagValue("foreign tag"), False)+ creator.create_domain("conflict", None, {}, "foreign tag", False)with self.assertRaises(NoSuchTagException):- creator.create_domain("missing", None, {}, TagValue("missing tag"), False)+ creator.create_domain("missing", None, {}, "missing tag", False)def test_authorization_member_access_without_tag_privileges(self):if not self.authorization:self.skipTest("Requires an authorization-enabled server")catalog, table, _, _, _, _, _ = self._catalogs()parent = self._domain("access_parent")- child = parent.create_subdomain(- "access_child", None, {}, TagValue("child tag"), True- )+ child = parent.create_subdomain("access_child", None, {}, "child tag", True)parent.publish()catalog.as_schemas().load_schema("schema").supports_tags().assign_tags(- [parent.backing_tag().name()]+ [parent.backing_tag()])table.supports_tags().assign_tags(["child tag"])@@ -679,7 +664,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):first = self._domain("first").publish()second = self._domain("second").publish()child = first.create_subdomain(- "moving_child_name", None, {}, TagValue("moving tag"), True+ "moving_child_name", None, {}, "moving tag", True).publish()manager = self._client("moving_manager")owner = self._client("lake_owner")@@ -774,111 +759,55 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):)self.assertIsNone(relation.source().parent())- def test_nearest_tag_assignment_and_value_matching(self):+ def test_membership_ignores_assignment_values(self):catalog, table = self._relational_table()- self.lake.create_tag("department", None, {}, ["finance", "risk", "Finance"])- finance = self.lake.create_domain(- "Finance", None, {}, TagValue("department", "finance"), False- )- risk = self.lake.create_domain(- "Risk", None, {}, TagValue("department", "risk"), False- )- capitalized = self.lake.create_domain(- "Capitalized", None, {}, TagValue("department", "Finance"), False+ # An existing tag with an allowed-values list backs a domain without a value.+ self.lake.create_tag("department", None, {}, ["finance", "risk"])+ finance = self.lake.create_domain("Finance", None, {}, "department", False)+ self.assertEqual(+ "department", self.lake.get_domain(finance.name()).backing_tag())++ # A tag backs at most one domain, whether bound at creation or later.+ with self.assertRaises(BackingTagAlreadyBoundException):+ self.lake.create_domain("Risk", None, {}, "department", False)+ risk = self._domain("Risk")+ with self.assertRaises(BackingTagAlreadyBoundException):+ risk.update_backing_tag("department")+inherited_catalog = (DomainRelation.Type.INHERITED,MetadataObject.Type.CATALOG,"ice",)- inherited_schema = (- DomainRelation.Type.INHERITED,- MetadataObject.Type.SCHEMA,- "ice.schema",- )direct = (DomainRelation.Type.DIRECT, None, None)- schema_tags = catalog.as_schemas().load_schema("schema").supports_tags()-- with self.assertRaises(IllegalArgumentException):- finance.update_backing_tag(TagValue("department", "unknown"))- self.assertEqual(- TagValue("department", "finance"),- self.lake.get_domain(finance.name()).backing_tag(),- )- # A nearer schema assignment masks the catalog's value of the same tag.- catalog.supports_tags().assign_tags(- [{"name": "department", "value": "finance"}]- )+ # Any value on an inherited or direct assignment matches.+ catalog.supports_tags().assign_tags([{"name": "department", "value": "risk"}])self._assert_table_relations(finance, table, {inherited_catalog})- self._assert_table_relations(capitalized, table, set())- schema_tags.assign_tags([{"name": "department", "value": "risk"}])- self._assert_table_relations(finance, table, set())- self._assert_table_relations(risk, table, {inherited_schema})-- # Each direct value matches exactly; remaining values still mask inherited assignments.- table.supports_tags().assign_tags(- [- {"name": "department", "value": "finance"},- {"name": "department", "value": "Finance"},- ]- )+ table.supports_tags().assign_tags([{"name": "department", "value": "finance"}])self._assert_table_relations(finance, table, {direct})- self._assert_table_relations(capitalized, table, {direct})- self._assert_table_relations(risk, table, set())- table.supports_tags().assign_tags(- tags_to_remove=[{"name": "department", "value": "finance"}]- )- self._assert_table_relations(finance, table, set())- self._assert_table_relations(capitalized, table, {direct})- self._assert_table_relations(risk, table, set())- # Removing assignments reveals the next ancestor, until no assignment remains.+ # Removing the direct assignment reveals the inherited one, then no membership.table.supports_tags().assign_tags(- tags_to_remove=[{"name": "department", "value": "Finance"}]- )- self._assert_table_relations(risk, table, {inherited_schema})- schema_tags.assign_tags(- tags_to_remove=[{"name": "department", "value": "risk"}]+ tags_to_remove=[{"name": "department", "value": "finance"}])self._assert_table_relations(finance, table, {inherited_catalog})catalog.supports_tags().assign_tags(- tags_to_remove=[{"name": "department", "value": "finance"}]- )- for domain in (finance, risk, capitalized):- self._assert_table_relations(domain, table, set())-- # A backing binding without a value matches any valued or valueless assignment.- self.lake.create_tag("any-value", None, {})- any_value = self.lake.create_domain(- "Any", None, {}, TagValue("any-value"), False- )- table.supports_tags().assign_tags([{"name": "any-value", "value": "arbitrary"}])- self._assert_table_relations(any_value, table, {direct})- table.supports_tags().assign_tags(- tags_to_remove=[{"name": "any-value", "value": "arbitrary"}]+ tags_to_remove=[{"name": "department", "value": "risk"}])- table.supports_tags().assign_tags(["any-value"])- self._assert_table_relations(any_value, table, {direct})- with self.assertRaises(BackingTagAlreadyBoundException):- self.lake.create_domain(- "Mixed", None, {}, TagValue("any-value", "arbitrary"), False- )+ self._assert_table_relations(finance, table, set())def test_multiple_subdomain_relations_and_backing_tag_identity(self):catalog, table = self._relational_table()parent = self._domain("Parent")- first = parent.create_subdomain(- "First_child_A", None, {}, TagValue("first-tag"), True- )- second = parent.create_subdomain(- "Second_child_B", None, {}, TagValue("second-tag"), True- )+ first = parent.create_subdomain("First_child_A", None, {}, "first-tag", True)+ second = parent.create_subdomain("Second_child_B", None, {}, "second-tag", True)catalog.supports_tags().assign_tags(["first-tag"])catalog.as_schemas().load_schema("schema").supports_tags().assign_tags(["second-tag"])- table.supports_tags().assign_tags([parent.backing_tag().name()])+ table.supports_tags().assign_tags([parent.backing_tag()])direct = (DomainRelation.Type.DIRECT, None, None)first_path = (DomainRelation.Type.VIA_SUBDOMAIN,@@ -936,7 +865,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):)# Removing one route must preserve the other routes and the member's own child scope.- table.supports_tags().assign_tags(tags_to_remove=[parent.backing_tag().name()])+ table.supports_tags().assign_tags(tags_to_remove=[parent.backing_tag()])self._assert_table_relations(parent, table, {first_path, second_path})second.detach_from_parent()self._assert_table_relations(parent, table, {first_path})@@ -958,7 +887,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):# Tag identity survives rename, but deletion and same-name recreation cannot restore a binding.self.lake.alter_tag("first-tag", TagChange.rename("renamed-first-tag"))self.assertEqual(- "renamed-first-tag", self.lake.get_domain(first.name()).backing_tag().name()+ "renamed-first-tag", self.lake.get_domain(first.name()).backing_tag())self._assert_table_relations(parent, table, {first_path})self.lake.delete_tag("renamed-first-tag")@@ -968,7 +897,7 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):catalog.supports_tags().assign_tags(["renamed-first-tag"])self._assert_table_relations(first, table, set())self._assert_table_relations(parent, table, set())- first.update_backing_tag(TagValue("renamed-first-tag"))+ first.update_backing_tag("renamed-first-tag")self._assert_table_relations(first, table, {inherited_catalog})self._assert_table_relations(parent, table, {first_path})first.update_backing_tag(None)@@ -977,20 +906,18 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):def test_invalid_hierarchy_atomic_creation_and_idempotence(self):parent = self._domain("Parent")other = self._domain("Other")- child = parent.create_subdomain("Child", None, {}, TagValue("child-tag"), True)+ child = parent.create_subdomain("Child", None, {}, "child-tag", True)self.lake.create_tag("existing-valued-tag", None, {}, ["finance"])bound = parent.create_subdomain("Bound","existing tag",{"key": "value"},- TagValue("existing-valued-tag", "finance"),+ "existing-valued-tag",False,)self.assertEqual(parent.name(), bound.parent())- self.assertEqual(- TagValue("existing-valued-tag", "finance"), bound.backing_tag()- )+ self.assertEqual("existing-valued-tag", bound.backing_tag())self.assertEqual({"key": "value"}, bound.properties())with self.assertRaises(DomainAlreadyExistsException):self.lake.alter_domain(other.name(), DomainChange.rename(parent.name()))@@ -998,17 +925,13 @@ class TestDomain(DomainApiEdgesMixin, IntegrationTestEnv):# Rejected hierarchy or duplicate-name creation must not leave a domain or backing tag.with self.assertRaises(IllegalArgumentException):- child.create_subdomain(- "Grandchild", None, {}, TagValue("grandchild-tag"), True- )+ child.create_subdomain("Grandchild", None, {}, "grandchild-tag", True)with self.assertRaises(NoSuchDomainException):self.lake.get_domain("Grandchild")with self.assertRaises(NoSuchTagException):self.lake.get_tag("grandchild-tag")with self.assertRaises(DomainAlreadyExistsException):- self.lake.create_domain(- parent.name(), None, {}, TagValue("unused-tag"), True- )+ self.lake.create_domain(parent.name(), None, {}, "unused-tag", True)with self.assertRaises(NoSuchTagException):self.lake.get_tag("unused-tag")for domain, target in ((child, child), (other, child), (parent, other)):diff --git a/clients/client-python/tests/unittests/test_domain_client.py b/clients/client-python/tests/unittests/test_domain_client.pyindex 51bc8cf68e..698b97402c 100644--- a/clients/client-python/tests/unittests/test_domain_client.py+++ b/clients/client-python/tests/unittests/test_domain_client.py@@ -115,7 +115,7 @@ class TestDomainClient(unittest.TestCase):"properties": {"a": "b"},"status": "draft","parent": None,- "backingTag": {"name": "department", "value": "finance"},+ "backingTag": {"name": "department"},"audit": {"creator": "user", "createTime": "2026-10-01T00:00:00Z"},}data.update(overrides)@@ -149,18 +149,25 @@ class TestDomainClient(unittest.TestCase):self.assertEqual("comment", domain.comment())self.assertEqual(Domain.Status.DRAFT, domain.status())self.assertIsNone(domain.parent())- self.assertEqual(TagValue("department", "finance"), domain.backing_tag())+ self.assertEqual("department", domain.backing_tag())self.assertEqual("user", domain.audit_info().creator())domain.properties()["a"] = "changed"self.assertEqual({"a": "b"}, domain.properties())self.assertEqual([], domain.relations())self.assertIsNone(self._domain(backingTag=None).backing_tag())+ def test_blank_backing_tag_in_response_is_rejected(self):+ for name in (" ", ""):+ with self.subTest(name=name):+ dto = DomainDTO.from_dict(self._dto(backingTag={"name": name}))+ with self.assertRaises(IllegalArgumentException):+ dto.validate()+def test_create_top_level_and_subdomain(self):for parent in (None, self.NAME):for create, tag in (- (True, TagValue("new/tag")),- (False, TagValue("dept", "finance")),+ (True, "new/tag"),+ (False, "dept"),):with self.subTest(parent=parent, create=create):self._respond(@@ -184,11 +191,7 @@ class TestDomainClient(unittest.TestCase):"comment": None,"properties": None,"parent": parent,- "backingTag": {- "name": tag.name(),- "value": tag.value(),- "create": create,- },+ "backingTag": {"name": tag, "create": create},},)@@ -317,11 +320,11 @@ class TestDomainClient(unittest.TestCase):),(old.detach_from_parent, "DELETE", "/parent", None, {"parent": None}),(- lambda: old.update_backing_tag(TagValue("tag/new", "v")),+ lambda: old.update_backing_tag("tag/new"),"PUT","/backingTag",- {"backingTag": {"name": "tag/new", "value": "v"}},- {"backingTag": {"name": "tag/new", "value": "v"}},+ {"backingTag": {"name": "tag/new"}},+ {"backingTag": {"name": "tag/new"}},),(lambda: old.update_backing_tag(None),@@ -338,7 +341,7 @@ class TestDomainClient(unittest.TestCase):self.assertIsNot(old, result)self.assertEqual(Domain.Status.DRAFT, old.status())self.assertIsNone(old.parent())- self.assertEqual(TagValue("department", "finance"), old.backing_tag())+ self.assertEqual("department", old.backing_tag())self.assertEqual(DomainDTO.from_dict(self._dto(**changes)).status(), result.status())@@ -681,15 +684,12 @@ class TestDomainClient(unittest.TestCase):request.validate()invalid_operations = (lambda: self.metalake.create_domain("name", None, None, None, False),+ lambda: self.metalake.create_domain("name", None, None, " ", True),+ lambda: self.metalake.create_domain(None, None, None, "tag", False),lambda: self.metalake.create_domain(- "name", None, None, TagValue("tag", "v"), True- ),- lambda: self.metalake.create_domain(- None, None, None, TagValue("tag"), False- ),- lambda: self.metalake.create_domain(- "name", None, {"key": None}, TagValue("tag"), False+ "name", None, {"key": None}, "tag", False),+ lambda: self._domain().update_backing_tag(" "),lambda: self.metalake.alter_domain("name", None),lambda: self.metalake.alter_domain("name", DomainChange.rename(None)),lambda: self.metalake.alter_domain(@@ -772,7 +772,7 @@ class TestDomainClient(unittest.TestCase):)dto = DomainDTO.from_json(json.dumps(data))self.assertEqual("child.with.dots", dto.relations()[0].source().name())- self.assertEqual(TagValue("department", "finance"), dto.backing_tag())+ self.assertEqual("department", dto.backing_tag())self.assertEqual(dto, DomainDTO.from_json(dto.to_json()))self.assertEqual("child.with.dots",@@ -821,7 +821,7 @@ class TestDomainClient(unittest.TestCase):self.assertEqual(self.NAME, client.get_domain(self.NAME).name())self.assertEqual(self.NAME,- client.create_domain(self.NAME, None, {}, TagValue("tag"), True).name(),+ client.create_domain(self.NAME, None, {}, "tag", True).name(),)self.assertEqual(self.NAME,diff --git a/common/src/main/java/org/apache/gravitino/dto/domain/DomainBackingTagDTO.java b/common/src/main/java/org/apache/gravitino/dto/domain/DomainBackingTagDTO.javaindex 1345032a9d..64bef155e3 100644--- a/common/src/main/java/org/apache/gravitino/dto/domain/DomainBackingTagDTO.java+++ b/common/src/main/java/org/apache/gravitino/dto/domain/DomainBackingTagDTO.java@@ -20,52 +20,32 @@ package org.apache.gravitino.dto.domain;import com.fasterxml.jackson.annotation.JsonProperty;import com.google.common.base.Preconditions;-import javax.annotation.Nullable;import lombok.Getter;import org.apache.commons.lang3.StringUtils;-import org.apache.gravitino.tag.TagValue;-/** A backing tag name and optional exact assignment value. */+/** The name of the tag that backs a domain. */@Getterpublic class DomainBackingTagDTO {@JsonProperty("name")private final String name;- @JsonProperty("value")- @Nullable- private final String value;-/** Creates a backing tag for Jackson deserialization. */public DomainBackingTagDTO() {- this(null, null);+ this(null);}/*** Creates a backing tag representation.** @param name The tag name.- * @param value The optional value; null matches any assignment.*/- public DomainBackingTagDTO(String name, @Nullable String value) {+ public DomainBackingTagDTO(String name) {this.name = name;- this.value = value;}- /** Validates the name and optional value. */+ /** Validates the name. */public void validate() {Preconditions.checkArgument(StringUtils.isNotBlank(name), "backingTag.name must not be blank");- Preconditions.checkArgument(- value == null || StringUtils.isNotBlank(value), "backingTag.value must not be blank");- Preconditions.checkArgument(- value == null || value.length() <= 256, "backingTag.value must not exceed 256 characters");- }-- /**- * @return The corresponding tag value.- */- public TagValue tagValue() {- validate();- return value == null ? TagValue.noValue(name) : TagValue.of(name, value);}}diff --git a/common/src/main/java/org/apache/gravitino/dto/domain/DomainDTO.java b/common/src/main/java/org/apache/gravitino/dto/domain/DomainDTO.javaindex 1ec7503a70..808a200bc1 100644--- a/common/src/main/java/org/apache/gravitino/dto/domain/DomainDTO.java+++ b/common/src/main/java/org/apache/gravitino/dto/domain/DomainDTO.java@@ -30,7 +30,6 @@ import lombok.NoArgsConstructor;import org.apache.gravitino.domain.Domain;import org.apache.gravitino.domain.DomainRelation;import org.apache.gravitino.dto.AuditDTO;-import org.apache.gravitino.tag.TagValue;/*** A domain snapshot; relations are present only in a metadata object's domain lookup. Jackson uses@@ -76,7 +75,7 @@ public class DomainDTO {* @param properties The properties.* @param status The status.* @param parent The optional parent name.- * @param backingTag The optional backing tag.+ * @param backingTag The name of the backing tag, or null if the domain has none.* @param audit The audit information.* @param relations The object's relations to this domain.*/@@ -86,7 +85,7 @@ public class DomainDTO {Map<String, String> properties,Domain.Status status,@Nullable String parent,- @Nullable TagValue backingTag,+ @Nullable String backingTag,AuditDTO audit,DomainRelation[] relations) {this.name = name;@@ -94,10 +93,7 @@ public class DomainDTO {this.properties = ImmutableMap.copyOf(properties);this.status = status;this.parent = parent;- this.backingTag =- backingTag == null- ? null- : new DomainBackingTagDTO(backingTag.name(), backingTag.value().orElse(null));+ this.backingTag = backingTag == null ? null : new DomainBackingTagDTO(backingTag);this.audit = audit;this.relations =Arrays.stream(relations).map(DomainRelationDTO::from).toArray(DomainRelationDTO[]::new);diff --git a/common/src/main/java/org/apache/gravitino/dto/requests/DomainCreateRequest.java b/common/src/main/java/org/apache/gravitino/dto/requests/DomainCreateRequest.javaindex d9acd58af6..c114de67ea 100644--- a/common/src/main/java/org/apache/gravitino/dto/requests/DomainCreateRequest.java+++ b/common/src/main/java/org/apache/gravitino/dto/requests/DomainCreateRequest.java@@ -92,7 +92,7 @@ public class DomainCreateRequest implements RESTRequest {backingTag.validate();}- /** A tag to create without a value, or an existing tag to bind. */+ /** A tag to create without values, or an existing tag to bind. */@Getterpublic static class BackingTag extends DomainBackingTagDTO {@@ -101,27 +101,18 @@ public class DomainCreateRequest implements RESTRequest {/** Creates a backing tag request for Jackson deserialization. */public BackingTag() {- this(null, null, false);+ this(null, false);}/*** Creates a backing tag request.** @param name The tag name.- * @param value The optional existing assignment value.* @param create Whether to create a new tag without values.*/- public BackingTag(String name, @Nullable String value, boolean create) {- super(name, value);+ public BackingTag(String name, boolean create) {+ super(name);this.create = create;}-- /** Validates the tag and prohibits creating a tag with a value. */- @Override- public void validate() {- super.validate();- Preconditions.checkArgument(- !create || getValue() == null, "A new backing tag cannot have a value");- }}}diff --git a/common/src/test/java/org/apache/gravitino/dto/domain/TestDomainDTO.java b/common/src/test/java/org/apache/gravitino/dto/domain/TestDomainDTO.javaindex c0aeda3a1f..3fefac00c6 100644--- a/common/src/test/java/org/apache/gravitino/dto/domain/TestDomainDTO.java+++ b/common/src/test/java/org/apache/gravitino/dto/domain/TestDomainDTO.java@@ -20,6 +20,7 @@package org.apache.gravitino.dto.domain;import com.fasterxml.jackson.databind.JsonNode;+import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;import java.io.IOException;import java.time.Instant;import java.util.Collections;@@ -34,7 +35,6 @@ import org.apache.gravitino.dto.AuditDTO;import org.apache.gravitino.dto.responses.DomainListResponse;import org.apache.gravitino.dto.responses.DomainMemberListResponse;import org.apache.gravitino.json.JsonUtils;-import org.apache.gravitino.tag.TagValue;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;@@ -42,7 +42,7 @@ public class TestDomainDTO {private static final String DOMAIN_JSON ="{\"name\":\"Finance\",\"comment\":\"Financial data\",\"properties\":{\"key\":\"value\"},"- + "\"status\":\"published\",\"parent\":\"Parent\",\"backingTag\":{\"name\":\"department\",\"value\":\"finance\"},"+ + "\"status\":\"published\",\"parent\":\"Parent\",\"backingTag\":{\"name\":\"finance\"},"+ "\"audit\":{\"creator\":\"user\",\"createTime\":\"2026-10-01T00:00:00Z\",\"lastModifier\":null,\"lastModifiedTime\":null},"+ "\"relations\":[{\"relation\":\"direct\"},{\"relation\":\"inherited\",\"source\":{\"type\":\"schema\",\"fullName\":\"cat.schema\"}},"+ "{\"relation\":\"via_subdomain\",\"source\":{\"type\":\"domain\",\"fullName\":\"Finance_US\"}}]}";@@ -89,9 +89,8 @@ public class TestDomainDTO {}@Test- public void testBackingTagValues() throws IOException {- for (TagValue tag :- new TagValue[] {TagValue.noValue("department"), TagValue.of("department", "finance")}) {+ public void testBackingTagName() throws IOException {+ for (String tag : new String[] {"finance", null}) {DomainDTO dto =new DomainDTO("Finance",@@ -105,8 +104,11 @@ public class TestDomainDTO {DomainDTO decoded =JsonUtils.objectMapper().readValue(JsonUtils.objectMapper().writeValueAsString(dto), DomainDTO.class);- Assertions.assertEquals(tag.name(), decoded.getBackingTag().getName());- Assertions.assertEquals(tag.value().orElse(null), decoded.getBackingTag().getValue());+ if (tag == null) {+ Assertions.assertNull(decoded.getBackingTag());+ } else {+ Assertions.assertEquals(tag, decoded.getBackingTag().getName());+ }Assertions.assertEquals("Parent", decoded.getParent());Assertions.assertEquals("comment", decoded.getComment());Assertions.assertEquals("user", decoded.getAudit().creator());@@ -174,7 +176,7 @@ public class TestDomainDTO {Collections.singletonMap("key", "value"),Domain.Status.PUBLISHED,"Parent",- TagValue.of("department", "finance"),+ "finance",AUDIT,new DomainRelation[] {DomainRelation.direct(),@@ -193,8 +195,7 @@ public class TestDomainDTO {Assertions.assertEquals(Collections.singletonMap("key", "value"), dto.getProperties());Assertions.assertEquals(Domain.Status.PUBLISHED, dto.getStatus());Assertions.assertEquals("Parent", dto.getParent());- Assertions.assertEquals("department", dto.getBackingTag().getName());- Assertions.assertEquals("finance", dto.getBackingTag().getValue());+ Assertions.assertEquals("finance", dto.getBackingTag().getName());Assertions.assertEquals(AUDIT, dto.getAudit());Assertions.assertEquals(3, dto.getRelations().length);Assertions.assertEquals(DomainRelation.Type.DIRECT, dto.getRelations()[0].getRelation());@@ -222,23 +223,17 @@ public class TestDomainDTO {@Testpublic void testBackingTagJson() throws IOException {- for (String json :- new String[] {- "{\"name\":\"department\",\"value\":\"finance\"}",- "{\"name\":\"department\",\"value\":null}"- }) {- DomainBackingTagDTO tag = JsonUtils.objectMapper().readValue(json, DomainBackingTagDTO.class);- Assertions.assertEquals("department", tag.getName());- Assertions.assertEquals(- JsonUtils.objectMapper().readTree(json).get("value").isNull() ? null : "finance",- tag.getValue());- tag.validate();- assertJsonEquals(json, tag);- }- DomainBackingTagDTO noValue =- JsonUtils.objectMapper().readValue("{\"name\":\"department\"}", DomainBackingTagDTO.class);- Assertions.assertNull(noValue.getValue());- assertJsonEquals("{\"name\":\"department\",\"value\":null}", noValue);+ DomainBackingTagDTO tag =+ JsonUtils.objectMapper().readValue("{\"name\":\"finance\"}", DomainBackingTagDTO.class);+ Assertions.assertEquals("finance", tag.getName());+ tag.validate();+ assertJsonEquals("{\"name\":\"finance\"}", tag);+ Assertions.assertThrows(+ UnrecognizedPropertyException.class,+ () ->+ JsonUtils.objectMapper()+ .readValue(+ "{\"name\":\"department\",\"value\":\"finance\"}", DomainBackingTagDTO.class));}@Testdiff --git a/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainBackingTagSetRequest.java b/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainBackingTagSetRequest.javaindex 2ecbf0d443..6570bd62e0 100644--- a/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainBackingTagSetRequest.java+++ b/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainBackingTagSetRequest.java@@ -20,10 +20,10 @@ package org.apache.gravitino.dto.requests;import com.fasterxml.jackson.annotation.JsonInclude;import com.fasterxml.jackson.databind.DeserializationFeature;+import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;import java.io.IOException;import org.apache.gravitino.dto.domain.DomainBackingTagDTO;import org.apache.gravitino.json.JsonUtils;-import org.apache.gravitino.tag.TagValue;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;@@ -66,15 +66,26 @@ public class TestDomainBackingTagSetRequest {public void testSetBinding() throws IOException {DomainBackingTagSetRequest request =JsonUtils.objectMapper()- .readValue(- "{\"backingTag\":{\"name\":\"department\",\"value\":\"finance\"}}",- DomainBackingTagSetRequest.class);+ .readValue("{\"backingTag\":{\"name\":\"finance\"}}", DomainBackingTagSetRequest.class);request.validate();- Assertions.assertEquals(- TagValue.of("department", "finance"), request.getBackingTag().tagValue());+ Assertions.assertEquals("finance", request.getBackingTag().getName());DomainBackingTagSetRequest direct =- new DomainBackingTagSetRequest(new DomainBackingTagDTO("department", null));+ new DomainBackingTagSetRequest(new DomainBackingTagDTO("finance"));direct.validate();- Assertions.assertEquals(TagValue.noValue("department"), direct.getBackingTag().tagValue());+ Assertions.assertEquals("finance", direct.getBackingTag().getName());+ Assertions.assertThrows(+ IllegalArgumentException.class,+ () -> new DomainBackingTagSetRequest(new DomainBackingTagDTO(" ")).validate());+ }++ @Test+ public void testValueIsRejected() {+ Assertions.assertThrows(+ UnrecognizedPropertyException.class,+ () ->+ JsonUtils.objectMapper()+ .readValue(+ "{\"backingTag\":{\"name\":\"department\",\"value\":\"finance\"}}",+ DomainBackingTagSetRequest.class));}}diff --git a/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainRequests.java b/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainRequests.javaindex 1145f060b1..b69585ab04 100644--- a/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainRequests.java+++ b/common/src/test/java/org/apache/gravitino/dto/requests/TestDomainRequests.java@@ -18,6 +18,7 @@*/package org.apache.gravitino.dto.requests;+import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;import java.io.IOException;import java.util.Arrays;import java.util.Collections;@@ -26,7 +27,6 @@ import org.apache.gravitino.domain.DomainChange;import org.apache.gravitino.dto.domain.DomainBackingTagDTO;import org.apache.gravitino.json.JsonUtils;import org.apache.gravitino.rest.RESTRequest;-import org.apache.gravitino.tag.TagValue;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;@@ -41,7 +41,7 @@ public class TestDomainRequests {"comment",Collections.singletonMap("k", "v"),"Parent",- new DomainCreateRequest.BackingTag("tag", create ? null : "value", create));+ new DomainCreateRequest.BackingTag("tag", create));DomainCreateRequest result = roundTrip(request, DomainCreateRequest.class);result.validate();Assertions.assertEquals("Finance", result.getName());@@ -49,9 +49,7 @@ public class TestDomainRequests {Assertions.assertEquals(Collections.singletonMap("k", "v"), result.getProperties());Assertions.assertEquals("Parent", result.getParent());Assertions.assertEquals(create, result.getBackingTag().isCreate());- Assertions.assertEquals(- create ? TagValue.noValue("tag") : TagValue.of("tag", "value"),- result.getBackingTag().tagValue());+ Assertions.assertEquals("tag", result.getBackingTag().getName());}DomainCreateRequest existing =JsonUtils.objectMapper()@@ -60,24 +58,28 @@ public class TestDomainRequests {DomainCreateRequest.class);existing.validate();Assertions.assertFalse(existing.getBackingTag().isCreate());- Assertions.assertEquals(TagValue.noValue("tag"), existing.getBackingTag().tagValue());+ Assertions.assertEquals("tag", existing.getBackingTag().getName());+ Assertions.assertThrows(+ UnrecognizedPropertyException.class,+ () ->+ JsonUtils.objectMapper()+ .readValue(+ "{\"name\":\"Finance\",\"backingTag\":{\"name\":\"tag\",\"value\":\"v\"}}",+ DomainCreateRequest.class));}@Testpublic void testBackingTagValidation() {for (DomainBackingTagDTO invalid :new DomainBackingTagDTO[] {- new DomainBackingTagDTO(), new DomainBackingTagDTO(" ", null),- new DomainBackingTagDTO("tag", " "),- new DomainBackingTagDTO("tag", String.join("", Collections.nCopies(257, "x"))),- new DomainCreateRequest.BackingTag("tag", "value", true)+ new DomainBackingTagDTO(),+ new DomainBackingTagDTO(" "),+ new DomainCreateRequest.BackingTag(" ", true)}) {Assertions.assertThrows(IllegalArgumentException.class, invalid::validate);- Assertions.assertThrows(IllegalArgumentException.class, invalid::tagValue);}- new DomainBackingTagDTO("tag", String.join("", Collections.nCopies(256, "x"))).validate();- Assertions.assertEquals(- TagValue.noValue("tag"), new DomainBackingTagDTO("tag", null).tagValue());+ new DomainBackingTagDTO("tag").validate();+ new DomainCreateRequest.BackingTag("tag", true).validate();}@Test@@ -91,14 +93,14 @@ public class TestDomainRequests {parent.validate();Assertions.assertEquals("Parent/US", parent.getParent());for (DomainBackingTagDTO tag :- new DomainBackingTagDTO[] {null, new DomainBackingTagDTO("tag", "value")}) {+ new DomainBackingTagDTO[] {null, new DomainBackingTagDTO("tag")}) {DomainBackingTagSetRequest request =roundTrip(new DomainBackingTagSetRequest(tag), DomainBackingTagSetRequest.class);request.validate();if (tag == null) {Assertions.assertNull(request.getBackingTag());} else {- Assertions.assertEquals(TagValue.of("tag", "value"), request.getBackingTag().tagValue());+ Assertions.assertEquals("tag", request.getBackingTag().getName());}}Assertions.assertThrows(@@ -111,15 +113,15 @@ public class TestDomainRequests {new RESTRequest[] {new DomainCreateRequest(),new DomainCreateRequest(- " ", null, null, null, new DomainCreateRequest.BackingTag("tag", null, false)),+ " ", null, null, null, new DomainCreateRequest.BackingTag("tag", false)),new DomainCreateRequest(- "Finance", null, null, " ", new DomainCreateRequest.BackingTag("tag", null, false)),+ "Finance", null, null, " ", new DomainCreateRequest.BackingTag("tag", false)),new DomainCreateRequest("Finance",null,Collections.singletonMap("key", null),null,- new DomainCreateRequest.BackingTag("tag", null, false)),+ new DomainCreateRequest.BackingTag("tag", false)),new DomainSetRequest(),new DomainParentSetRequest(),new DomainParentSetRequest(" "),diff --git a/core/src/main/java/org/apache/gravitino/domain/DomainManager.java b/core/src/main/java/org/apache/gravitino/domain/DomainManager.javaindex 8e38e4b78d..b279ef1e0a 100644--- a/core/src/main/java/org/apache/gravitino/domain/DomainManager.java+++ b/core/src/main/java/org/apache/gravitino/domain/DomainManager.java@@ -651,14 +651,14 @@ public class DomainManager implements DomainDispatcher {!Objects.equals(name, parent), "Domain %s cannot be its own parent", name);}- // Checks that the locked backing tag allows the value and that no other domain has a binding of- // the tag that conflicts with it: a tag has either one binding without a value, or bindings with- // values where each value backs at most one domain.+ // Checks that the locked backing tag allows the value, if any, and that no other domain has a+ // binding of the tag that conflicts with it: a tag has either one binding without a value, or+ // bindings with values where each value backs at most one domain. A binding without a value+ // matches every assignment of the tag, so it is accepted whatever values the tag allows.private static void checkBinding(DomainEntity domain, Optional<String> value, LockedDomainState state) {TagEntity tag = lockedBackingTag(state);- tag.validateAllowedValue(- value.map(v -> TagValue.of(tag.name(), v)).orElseGet(() -> TagValue.noValue(tag.name())));+ value.ifPresent(v -> tag.validateAllowedValue(TagValue.of(tag.name(), v)));for (DomainEntity bound : state.backingTagBindings()) {if (Objects.equals(bound.id(), domain.id())) {diff --git a/core/src/main/java/org/apache/gravitino/listener/DomainEventDispatcher.java b/core/src/main/java/org/apache/gravitino/listener/DomainEventDispatcher.javaindex 360b10ffbb..98b071e10e 100644--- a/core/src/main/java/org/apache/gravitino/listener/DomainEventDispatcher.java+++ b/core/src/main/java/org/apache/gravitino/listener/DomainEventDispatcher.java@@ -164,7 +164,8 @@ public final class DomainEventDispatcher implements DomainDispatcher {boolean createBackingTag) {String user = PrincipalUtils.getCurrentUserName();DomainInfo requested =- new DomainInfo(name, comment, properties, Domain.Status.DRAFT, null, backingTag, null);+ new DomainInfo(+ name, comment, properties, Domain.Status.DRAFT, null, tagName(backingTag), null);eventBus.dispatchEvent(new CreateDomainPreEvent(user, metalake, name, requested, createBackingTag));try {@@ -193,7 +194,8 @@ public final class DomainEventDispatcher implements DomainDispatcher {boolean createBackingTag) {String user = PrincipalUtils.getCurrentUserName();DomainInfo requested =- new DomainInfo(name, comment, properties, Domain.Status.DRAFT, parent, backingTag, null);+ new DomainInfo(+ name, comment, properties, Domain.Status.DRAFT, parent, tagName(backingTag), null);eventBus.dispatchEvent(new CreateDomainPreEvent(user, metalake, name, requested, createBackingTag));try {@@ -307,15 +309,17 @@ public final class DomainEventDispatcher implements DomainDispatcher {public DomainEntity updateBackingTag(String metalake, String name, @Nullable TagValue backingTag) {String user = PrincipalUtils.getCurrentUserName();- eventBus.dispatchEvent(new UpdateDomainBackingTagPreEvent(user, metalake, name, backingTag));+ eventBus.dispatchEvent(+ new UpdateDomainBackingTagPreEvent(user, metalake, name, tagName(backingTag)));try {DomainEntity result = dispatcher.updateBackingTag(metalake, name, backingTag);eventBus.dispatchEvent(- new UpdateDomainBackingTagEvent(user, metalake, name, backingTag, domainInfo(result)));+ new UpdateDomainBackingTagEvent(+ user, metalake, name, tagName(backingTag), domainInfo(result)));return result;} catch (Exception e) {eventBus.dispatchEvent(- new UpdateDomainBackingTagFailureEvent(user, metalake, name, backingTag, e));+ new UpdateDomainBackingTagFailureEvent(user, metalake, name, tagName(backingTag), e));throw e;}}@@ -413,7 +417,12 @@ public final class DomainEventDispatcher implements DomainDispatcher {domain.properties(),domain.status(),domain.parent().orElse(null),- domain.backingTag().orElse(null),+ domain.backingTag().map(TagValue::name).orElse(null),domain.auditInfo());}++ @Nullable+ private static String tagName(@Nullable TagValue backingTag) {+ return backingTag == null ? null : backingTag.name();+ }}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagEvent.javaindex 76512b34f1..304209832b 100644--- a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagEvent.java+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagEvent.java@@ -22,13 +22,12 @@ import javax.annotation.Nullable;import org.apache.gravitino.annotation.DeveloperApi;import org.apache.gravitino.listener.api.event.OperationType;import org.apache.gravitino.listener.api.info.DomainInfo;-import org.apache.gravitino.tag.TagValue;import org.apache.gravitino.utils.NameIdentifierUtil;/** The success event for UpdateDomainBackingTag. */@DeveloperApipublic final class UpdateDomainBackingTagEvent extends DomainEvent {- private final @Nullable TagValue backingTag;+ private final @Nullable String backingTag;private final DomainInfo domainInfo;/**@@ -37,14 +36,14 @@ public final class UpdateDomainBackingTagEvent extends DomainEvent {* @param user The initiating user.* @param metalake The metalake name.* @param name The domain name addressed by the operation.- * @param backingTag The requested backing tag, or null to remove it.+ * @param backingTag The name of the requested backing tag, or null to remove it.* @param domainInfo The requested or returned domain snapshot.*/public UpdateDomainBackingTagEvent(String user,String metalake,String name,- @Nullable TagValue backingTag,+ @Nullable String backingTag,DomainInfo domainInfo) {super(user, NameIdentifierUtil.ofDomain(metalake, name));this.backingTag = backingTag;@@ -52,9 +51,9 @@ public final class UpdateDomainBackingTagEvent extends DomainEvent {}/**- * @return The requested backing tag, or null to remove it.+ * @return The name of the requested backing tag, or null to remove it.*/- public @Nullable TagValue backingTag() {+ public @Nullable String backingTag() {return backingTag;}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagFailureEvent.javaindex 732380bbcd..7d46c52666 100644--- a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagFailureEvent.java+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagFailureEvent.java@@ -21,13 +21,12 @@ package org.apache.gravitino.listener.api.event.domain;import javax.annotation.Nullable;import org.apache.gravitino.annotation.DeveloperApi;import org.apache.gravitino.listener.api.event.OperationType;-import org.apache.gravitino.tag.TagValue;import org.apache.gravitino.utils.NameIdentifierUtil;/** The failure event for UpdateDomainBackingTag. */@DeveloperApipublic final class UpdateDomainBackingTagFailureEvent extends DomainFailureEvent {- private final @Nullable TagValue backingTag;+ private final @Nullable String backingTag;/*** Creates the event.@@ -35,23 +34,19 @@ public final class UpdateDomainBackingTagFailureEvent extends DomainFailureEvent* @param user The initiating user.* @param metalake The metalake name.* @param name The domain name addressed by the operation.- * @param backingTag The requested backing tag, or null to remove it.+ * @param backingTag The name of the requested backing tag, or null to remove it.* @param exception The operation failure.*/public UpdateDomainBackingTagFailureEvent(- String user,- String metalake,- String name,- @Nullable TagValue backingTag,- Exception exception) {+ String user, String metalake, String name, @Nullable String backingTag, Exception exception) {super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);this.backingTag = backingTag;}/**- * @return The requested backing tag, or null to remove it.+ * @return The name of the requested backing tag, or null to remove it.*/- public @Nullable TagValue backingTag() {+ public @Nullable String backingTag() {return backingTag;}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagPreEvent.javaindex 5af43543db..778ac70db1 100644--- a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagPreEvent.java+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagPreEvent.java@@ -21,13 +21,12 @@ package org.apache.gravitino.listener.api.event.domain;import javax.annotation.Nullable;import org.apache.gravitino.annotation.DeveloperApi;import org.apache.gravitino.listener.api.event.OperationType;-import org.apache.gravitino.tag.TagValue;import org.apache.gravitino.utils.NameIdentifierUtil;/** The pre event for UpdateDomainBackingTag. */@DeveloperApipublic final class UpdateDomainBackingTagPreEvent extends DomainPreEvent {- private final @Nullable TagValue backingTag;+ private final @Nullable String backingTag;/*** Creates the event.@@ -35,18 +34,18 @@ public final class UpdateDomainBackingTagPreEvent extends DomainPreEvent {* @param user The initiating user.* @param metalake The metalake name.* @param name The domain name addressed by the operation.- * @param backingTag The requested backing tag, or null to remove it.+ * @param backingTag The name of the requested backing tag, or null to remove it.*/public UpdateDomainBackingTagPreEvent(- String user, String metalake, String name, @Nullable TagValue backingTag) {+ String user, String metalake, String name, @Nullable String backingTag) {super(user, NameIdentifierUtil.ofDomain(metalake, name));this.backingTag = backingTag;}/**- * @return The requested backing tag, or null to remove it.+ * @return The name of the requested backing tag, or null to remove it.*/- public @Nullable TagValue backingTag() {+ public @Nullable String backingTag() {return backingTag;}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/info/DomainInfo.java b/core/src/main/java/org/apache/gravitino/listener/api/info/DomainInfo.javaindex bffa67e740..b88f7d86f1 100644--- a/core/src/main/java/org/apache/gravitino/listener/api/info/DomainInfo.java+++ b/core/src/main/java/org/apache/gravitino/listener/api/info/DomainInfo.java@@ -25,7 +25,6 @@ import javax.annotation.Nullable;import org.apache.gravitino.Audit;import org.apache.gravitino.annotation.DeveloperApi;import org.apache.gravitino.domain.Domain;-import org.apache.gravitino.tag.TagValue;/** A domain snapshot for event listeners, without storage identifiers. */@DeveloperApi@@ -35,7 +34,7 @@ public final class DomainInfo {private final Map<String, String> properties;private final Domain.Status status;@Nullable private final String parent;- @Nullable private final TagValue backingTag;+ @Nullable private final String backingTag;@Nullable private final Audit audit;/**@@ -46,7 +45,7 @@ public final class DomainInfo {* @param properties The properties, or null for none.* @param status The domain status.* @param parent The parent name, or null for a top-level domain.- * @param backingTag The backing tag, or null if unbound.+ * @param backingTag The name of the backing tag, or null if unbound.* @param audit The audit information, or null for a creation request.*/public DomainInfo(@@ -55,7 +54,7 @@ public final class DomainInfo {@Nullable Map<String, String> properties,Domain.Status status,@Nullable String parent,- @Nullable TagValue backingTag,+ @Nullable String backingTag,@Nullable Audit audit) {this.name = name;this.comment = comment;@@ -97,9 +96,9 @@ public final class DomainInfo {return Optional.ofNullable(parent);}/**- * @return The backing tag, or empty if unbound.+ * @return The name of the backing tag, or empty if unbound.*/- public Optional<TagValue> backingTag() {+ public Optional<String> backingTag() {return Optional.ofNullable(backingTag);}/**diff --git a/core/src/test/java/org/apache/gravitino/domain/TestDomainManager.java b/core/src/test/java/org/apache/gravitino/domain/TestDomainManager.javaindex 00af56208d..890ee25a1b 100644--- a/core/src/test/java/org/apache/gravitino/domain/TestDomainManager.java+++ b/core/src/test/java/org/apache/gravitino/domain/TestDomainManager.java@@ -950,11 +950,6 @@ public class TestDomainManager {() ->domainManager.createDomain(METALAKE, "Markets", null, null, TagValue.of("dept", "other"), false));- Assertions.assertThrows(- IllegalArgumentException.class,- () ->- domainManager.createDomain(- METALAKE, "Markets", null, null, TagValue.noValue("dept"), false));Assertions.assertThrows(IllegalArgumentException.class,() ->@@ -992,6 +987,51 @@ public class TestDomainManager {.orElse(null));}+ @Test+ public void testBindTagWithAllowedValuesWithoutValue() throws IOException {+ createTag("region", TagValueConstraint.ofAllowedValues("emea", "apac"));+ createTag("dept", TagValueConstraint.ofAllowedValues("finance", "markets"));++ // A tag that requires values on assignments can still back a domain without a value.+ DomainEntity emea =+ domainManager.createDomain(METALAKE, "Emea", null, null, TagValue.noValue("region"), false);+ Assertions.assertEquals(TagValue.noValue("region"), emea.backingTag().orElse(null));+ DomainEntity markets =+ domainManager.createDomain(+ METALAKE, "Markets", null, null, TagValue.noValue("dept"), false);+ DomainEntity child =+ domainManager.createSubdomain(+ METALAKE, "Markets", "Child", null, null, TagValue.noValue("plain_child"), true);+ Assertions.assertEquals(TagValue.noValue("plain_child"), child.backingTag().orElse(null));++ // A tag backs at most one domain, at creation and on update.+ Assertions.assertThrows(+ BackingTagAlreadyBoundException.class,+ () ->+ domainManager.createDomain(+ METALAKE, "Apac", null, null, TagValue.noValue("region"), false));+ Assertions.assertThrows(+ BackingTagAlreadyBoundException.class,+ () ->+ domainManager.createSubdomain(+ METALAKE, "Markets", "Apac", null, null, TagValue.noValue("region"), false));+ Assertions.assertThrows(+ BackingTagAlreadyBoundException.class,+ () -> domainManager.updateBackingTag(METALAKE, "Child", TagValue.noValue("region")));+ Assertions.assertThrows(+ NoSuchDomainException.class, () -> domainManager.getDomain(METALAKE, "Apac"));++ // A domain can move to a tag with allowed values once no other domain uses that tag.+ domainManager.updateBackingTag(METALAKE, "Emea", null);+ Assertions.assertEquals(+ TagValue.noValue("region"),+ domainManager+ .updateBackingTag(METALAKE, "Child", TagValue.noValue("region"))+ .backingTag()+ .orElse(null));+ Assertions.assertEquals(markets, domainManager.getDomain(METALAKE, "Markets"));+ }+@Testpublic void testUpdateBackingTag() throws IOException {createTag("dept", TagValueConstraint.ofAllowedValues("finance", "markets"));diff --git a/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.java b/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.javaindex 67031817a7..847595bd5e 100644--- a/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.java+++ b/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.java@@ -605,6 +605,23 @@ class TestDomainMembershipResolver {1, resolver.listMembers(METALAKE, anyValue, new DomainEntity[] {anyValue}, all()).length);}+ @Test+ void testBindingWithoutValueIgnoresAssignmentValues() {+ DomainEntity dept = domain(1, "Dept", null, 10L, null);+ DomainEntity[] domains = {dept};+ candidate(10, TABLE);+ assign(SCHEMA, tag(10, "dept", "finance"));+ assertEquals(1, resolver.listMembers(METALAKE, dept, domains, all()).length);+ assertEquals("Dept", listDomains(METALAKE, TABLE, domains)[0].name());+ // A nearer assignment with another value of the same tag keeps the object a member.+ assign(TABLE, tag(10, "dept", "hr"));+ assertEquals(1, resolver.listMembers(METALAKE, dept, domains, all()).length);+ assertEquals(1, listDomains(METALAKE, TABLE, domains).length);+ assign(TABLE, tag(10, "dept"));+ assertEquals(1, resolver.listMembers(METALAKE, dept, domains, all()).length);+ assertEquals(1, listDomains(METALAKE, TABLE, domains).length);+ }+@Testvoid testIdNotNameAndMissingBinding() {DomainEntity domain = domain(1, "Finance", null, 10L, null);diff --git a/core/src/test/java/org/apache/gravitino/listener/TestDomainEventDispatcher.java b/core/src/test/java/org/apache/gravitino/listener/TestDomainEventDispatcher.javaindex 9cb040a963..7052429b96 100644--- a/core/src/test/java/org/apache/gravitino/listener/TestDomainEventDispatcher.java+++ b/core/src/test/java/org/apache/gravitino/listener/TestDomainEventDispatcher.java@@ -244,6 +244,28 @@ class TestDomainEventDispatcher {verifyNoInteractions(hooks);}+ @Test+ void testNullBackingTagEmitsFailure() {+ DomainDispatcher delegate = mock(DomainDispatcher.class);+ when(delegate.createDomain(metalake, name, comment, properties, null, false))+ .thenThrow(new IllegalArgumentException("null backing tag"));+ when(delegate.createSubdomain(metalake, parent, name, comment, properties, null, false))+ .thenThrow(new IllegalArgumentException("null backing tag"));+ DomainEventDispatcher events = new DomainEventDispatcher(bus, delegate);+ assertThrows(+ IllegalArgumentException.class,+ () -> events.createDomain(metalake, name, comment, properties, null, false));+ assertThrows(+ IllegalArgumentException.class,+ () -> events.createSubdomain(metalake, parent, name, comment, properties, null, false));+ assertEquals(4, observed.size());+ for (int i = 0; i < 4; i += 2) {+ CreateDomainPreEvent pre = (CreateDomainPreEvent) observed.get(i);+ assertFalse(pre.domainInfo().backingTag().isPresent());+ assertInstanceOf(CreateDomainFailureEvent.class, observed.get(i + 1));+ }+ }+@Testvoid testCreateDomain() {verifyOperation(@@ -441,6 +463,15 @@ class TestDomainEventDispatcher {assertFalse(((UpdateDomainBackingTagEvent) observed.get(1)).domainInfo().backingTag().isPresent());observed.clear();+ when(delegate.updateBackingTag(metalake, name, backingTag)).thenReturn(domain);+ dispatcher.updateBackingTag(metalake, name, backingTag);+ assertEquals(+ backingTag.name(), ((UpdateDomainBackingTagPreEvent) observed.get(0)).backingTag());+ assertEquals(backingTag.name(), ((UpdateDomainBackingTagEvent) observed.get(1)).backingTag());+ assertEquals(+ backingTag.name(),+ ((UpdateDomainBackingTagEvent) observed.get(1)).domainInfo().backingTag().orElse(null));+ observed.clear();when(delegate.attachDomain(metalake, name, parent)).thenReturn(domain);dispatcher.attachDomain(metalake, name, parent);assertEquals(parent, ((AttachDomainPreEvent) observed.get(0)).parent());@@ -672,7 +703,7 @@ class TestDomainEventDispatcher {assertEquals(properties, info.properties());assertEquals(status, info.status());assertEquals(expectedParent, info.parent().orElse(null));- assertEquals(backingTag, info.backingTag().orElse(null));+ assertEquals(backingTag.name(), info.backingTag().orElse(null));assertEquals(audit, info.auditInfo());}}diff --git a/design-docs/domain-design.md b/design-docs/domain-design.mdindex d2637cce80..dc3ade7c96 100644--- a/design-docs/domain-design.md+++ b/design-docs/domain-design.md@@ -58,23 +58,23 @@ DomainRel { parentId, childId, audit_info } // one edge per subdomain- Domains live under a metalake. A subdomain and its parent are in the same metalake.- Domain names are unique within a metalake across both levels: top-level domains and subdomains share one namespace, so a domain is addressed by its name alone. Domain names follow the same constraints as tag names (up to 128 characters) and may contain `/` (see REST API, Encoding).- A unique index on `DomainRel (child_id, deleted_at)` keeps one parent per domain. `parent` is not stored on `Domain`; the API derives it. Dropping the index and checks would allow multiple parents later without a data migration.-- The backing tag is stored on the domain row as the tag's ID and an optional value, with an index on `(metalake_id, backing_tag_id, backing_tag_value, deleted_at)` for the reverse lookup "which domain does this (tag, value) back". `DOMAIN` is not a taggable object type, so the tag code paths are unchanged (see Alternatives considered).+- The backing tag is stored on the domain row as the tag's ID, with an index on `(metalake_id, backing_tag_id, backing_tag_value, deleted_at)` for the reverse lookup "which domain does this tag back". The `backing_tag_value` column is kept in storage for a possible future extension, but the API never sets it. Domains created by 2.0.0 development builds with a value keep filtering membership by it; to clear the values, bind each domain to its own tag with `PUT /domains/{domain}/backingTag`. When several domains share one tag through different values (for example `department=finance` and `department=risk`), the existing assignments stay on the old tag, so switching to dedicated tags drops every member that carries only the old tag. Copying container assignments can widen membership: with `department=finance` on a schema and `department=risk` on a table beneath it, tagging the schema with Finance's new tag also makes the table a Finance member. To preserve the existing leaf memberships: (1) record each domain's own leaf members with `GET /domains/{domain}/objects?expand=true`, keeping those whose relations include Direct or Inherited; (2) create the dedicated tags and assign each directly to the recorded leaves of its domain; (3) switch the bindings to the dedicated tags; (4) optionally remove the old tag's assignments by name. These steps preserve the set of leaves recorded at conversion time, not container membership: a tagged schema or catalog drops out of the default member listing, its inventoried leaves become direct members, and leaves outside the inventory, including external tables first recorded after the switch, no longer inherit the domain from that container. To keep a container's future leaves, the dedicated tag can also be assigned to the container, but only when every existing leaf that would inherit it is already in that domain's recorded inventory; a leaf whose own old-tag assignment overrode the container's (for example `department=engineering` under a `department=finance` schema, even when no domain is backed by `engineering`) would otherwise gain membership. Different tags resolve independently, so after that change every future leaf under the container inherits the dedicated tag, including one later assigned the old tag with another value, such as `department=risk`. The member list is filtered by object visibility, so the operator needs read and tag-assignment access to every affected object; an object missing from the inventory loses its membership when the binding changes. `DOMAIN` is not a taggable object type, so the tag code paths are unchanged (see Alternatives considered).- The binding refers to the tag by ID, and every membership path (member listing, domains of an object) looks up and compares tag IDs, never tag names: if the tag is deleted, the ID stays on the row and matches nothing, and a new tag with the same name does not match it, even if it is recreated while a request is running.- Domains, their parent and their backing tag are not cached; every request reads them from the store, so all servers see a move or a backing-tag change at once. Caching them later needs a version bump of the affected domain rows and a changelog entry.### Backing tag-Each domain has **at most one** backing tag: an existing tag, optionally with a value (tag values: apache/gravitino#12162). Creating a domain always sets one; a domain has none only after its backing tag is removed or deleted, until a new one is set.+Each domain has **at most one** backing tag, identified by name in the API and applied with no value. Creating a domain always sets one; a domain has none only after its backing tag is removed or deleted, until a new one is set.- **Explicit at creation**: every create request names the backing tag; there is no default name derived from the domain. The caller either- creates a new tag: a tag without values (`NO_VALUE`) with the given name, owned by the caller, which needs `CREATE_TAG`. If a tag with that name exists, creation fails with 409 `TagAlreadyExistsException`; an existing tag is never adopted implicitly; or- - binds an existing (tag, value), such as `dept=finance`. The caller must own the tag or the metalake; a missing tag fails with 404.+ - binds an existing tag, whatever values it allows. The caller must own the tag or the metalake; a missing tag fails with 404.- A create request without a backing tag, or one that creates a new tag and also gives a value, fails with 400.-- **Tag value rules apply as for any assignment**: a tag with a non-empty allowed-values list can only be bound with one of its values; a `NO_VALUE` tag only without a value.-- **No sharing**: following the tag assignment rules, a tag has either one binding without a value, or bindings with values where each value backs at most one domain; the two are never mixed. A conflicting binding fails with 409 `BackingTagAlreadyBoundException` (a new `AlreadyExistsException` subclass). The reverse lookup is therefore one domain per (tag, value).-- **Matching** follows the tag lookup semantics (`GET /tags/{tag}/objects`). A backing tag without a value matches every assignment of the tag, with or without values, like a lookup without `value`. A backing tag with a value matches assignments whose values contain it, exact and case-sensitive, like `?value=`; a valueless assignment never matches it. The same rule applies to member listing and domains of an object, always against the object's effective assignment.-- **Changing it**: `PUT /domains/{domain}/backingTag` replaces or removes it on the server, under the domain and tag row locks. A missing tag fails with 404, a value the tag does not allow with 400, a tag the caller does not own (nor the metalake) with 403, and a binding that conflicts with another domain with 409; setting the current tag is a no-op. Assets carrying only the old tag drop out; nothing is migrated. This endpoint is the only way to change a backing tag: `DOMAIN` is not taggable, so the generic tag association API rejects it.+ A create request without a backing tag fails with 400.+- **Any existing tag can be bound**: the binding has no value, so it is not checked against the tag's allowed values.+- **No sharing**: a tag backs at most one domain. Binding a tag that already backs another domain fails with 409 `BackingTagAlreadyBoundException` (a new `AlreadyExistsException` subclass). The reverse lookup is therefore one domain per tag.+- **Matching** depends only on the presence of the tag: every assignment of the backing tag matches, with or without values, like `GET /tags/{tag}/objects` without `value`. Any value on an assignment is ignored. The same rule applies to member listing and domains of an object, always against the object's effective assignment.+- **Changing it**: `PUT /domains/{domain}/backingTag` replaces or removes it on the server, under the domain and tag row locks. A missing tag fails with 404, a tag the caller does not own (nor the metalake) with 403, and a tag that already backs another domain with 409; setting the current tag is a no-op. Assets carrying only the old tag drop out; nothing is migrated. This endpoint is the only way to change a backing tag: `DOMAIN` is not taggable, so the generic tag association API rejects it.- **Never renamed**: moving or renaming a domain does not rename its tag; the hierarchy lives in `DomainRel`. A renamed tag keeps backing the domain, since the binding is by tag ID.- **Deleting the tag** behaves as for any tag: it is allowed, and the tag's assignments on assets are removed with it. Its domain is left with no backing tag (`backingTag` reads as empty) and no members until a new one is set; the membership cannot be recovered by recreating a tag with the same name. Only the tag deletion event records this.- **Separate from domain privileges**: the domain owner and the tag owner are independent. Managing a domain grants no `APPLY_TAG` on its tag, and transferring the domain's ownership does not transfer the tag's.@@ -105,7 +105,7 @@ Domain operations use the store's existing locking primitives, in one global ord| Operation | Rows locked | Conflicts it excludes || :---------------------------- | :------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------- |-| Create a top-level domain | metalake (shared) → existing tag (exclusive) | metalake drop; two domains binding the same (tag, value) |+| Create a top-level domain | metalake (shared) → existing tag (exclusive) | metalake drop; two domains binding the same tag || Create a subdomain | metalake (shared) → parent (shared) → existing tag (exclusive) | the parent being attached elsewhere (C2) || Attach / move | child (exclusive) and new parent (shared), in ID order | the new parent being attached elsewhere (C2); a subdomain being created under the child (C3); crossing moves || Detach | child (exclusive) | |@@ -134,9 +134,8 @@ Domain operations use the store's existing locking primitives, in one global ord### Membership and inheritance-- **Rule**: an object's effective tags are its own plus its schema's and catalog's; for the same tag the nearest level wins, and different tags accumulate. A leaf object (see Member types) is a member of domain D when its effective tags match D's backing (tag, value). Membership reuses core's `EffectiveTagResolver`, which applies no tag-privilege filtering: domain visibility and object access are applied afterwards, so a caller needs no tag privilege.+- **Rule**: an object's effective tags are its own plus its schema's and catalog's; for the same tag the nearest level wins, and different tags accumulate. A leaf object (see Member types) is a member of domain D when its effective tags include D's backing tag. Membership reuses core's `EffectiveTagResolver`, which applies no tag-privilege filtering: domain visibility and object access are applied afterwards, so a caller needs no tag privilege.- **Different tags accumulate**: with schema `finance` and table `sales`, the table is in both Finance and Sales, and a child cannot leave a domain it inherits.-- **Values of one tag** backing different domains override each other: with schema `dept=finance` and table `dept=hr`, the table is only in the `dept=hr` domain, unless it uses `dept=[finance, hr]`. This is the one case where a child can leave an inherited domain, and only for bindings with a value; a binding without a value matches every value.- **Member types**: the default listing returns directly tagged catalogs, schemas and leaves. The leaf types are tables, views, filesets, topics, models and semantic models. Expanded listing and object-to-domain lookup support these leaf types. Columns and functions are excluded.- **Relations**: expanded listing and object-to-domain lookup report the following relations for a leaf. Direct listing reports Direct and Via subdomain for assignments on the object itself:@@ -148,16 +147,16 @@ Domain operations use the store's existing locking primitives, in one global ordIn an expanded listing, every relation that applies is reported, as a list of (relation, source) pairs, with no precedence: a table whose schema carries `finance` and which itself carries `trading` gets `[Inherited from cat.db, Via subdomain Trading]` under Finance, and an object in two subdomains gets one Via subdomain pair for each. Clients decide how to display them. Relations are always relative to the listed domain. An object is a member of the domain itself when its relations include Direct or Inherited. The relation is an enum; the exact field shape is an implementation choice.- **Domains of an object**: for a leaf object, every domain the caller can see whose scope contains the object, each with its relations. An object tagged only `trading` gets Trading (Direct) and Finance (Via subdomain Trading). This reverse lookup remains limited to leaves even though forward listing can return catalogs and schemas.-- **Removing a member**: membership ends when the object no longer carries the backing tag, by the tag rules. To take an object out of a domain backed by a tag without a value, remove the tag by name (v1 association request), which removes all its values on the object; a v2 request removes one (tag, value) pair. An inherited membership can only be removed on the catalog or schema.+- **Removing a member**: membership ends when the object no longer carries the backing tag, by the tag rules. To take an object out of a domain, remove the tag by name (v1 association request), which removes all its values on the object. An inherited membership can only be removed on the catalog or schema.- **Domain filters**: Phase 1 adds no domain filter to other list APIs. When one is added, it matches scope, consistent with member listing.### Member listing-`GET /domains/{domain}/objects` defaults to direct assignments. Look up the selected domains' backing tags by stable ID and optional assignment value. A recreated tag with the same name has a different ID and cannot take over the binding.+`GET /domains/{domain}/objects` defaults to direct assignments. Look up the selected domains' backing tags by stable ID; assignment values are ignored. A recreated tag with the same name has a different ID and cannot take over the binding.Return each accessible matching object once with its relations to the queried domain and its visible subdomains. If a schema and a table under it both carry matching assignments, both appear. A leaf that matches solely through inheritance appears only with `expand=true`.-With `expand=true`, enumerate recorded leaves under each tagged container and check each leaf's effective tags against the selected bindings. A nearer assignment can override an inherited value.+With `expand=true`, enumerate recorded leaves under each tagged container and check each leaf's effective tags against the selected bindings.- **A view of recorded objects**: membership is defined by the rule above; the listing shows the objects recorded in Gravitino's store. Objects in an external catalog that Gravitino has not recorded yet are not listed, so an empty listing does not mean an object is not a member.- **Cost**: expanding a domain backed by a tag on a large catalog visits every recorded leaf object under it (see Open Questions).@@ -193,7 +192,7 @@ With `expand=true`, enumerate recorded leaves under each tagged container and ch| Publish, unpublish, edit, delete | `MANAGE_DOMAIN` |- **Membership is controlled by tag privileges only**: anyone with read access to an asset and `APPLY_TAG` on a backing tag can add the asset, without the asset owner's consent. This is the existing tag behavior; a steward controls membership by controlling `APPLY_TAG` on the backing tag.-- Browsing without `VIEW_TAG` is safe because only a tag's owner can bind it to a domain: exposing that one (tag, value) to the domain's viewers is the owner's decision, and viewers still see only objects they can access.+- Browsing without `VIEW_TAG` is safe because only a tag's owner can bind it to a domain: exposing that one tag to the domain's viewers is the owner's decision, and viewers still see only objects they can access.- A user with `MANAGE_DOMAIN` but no `APPLY_TAG` on the tag can manage the domain but not add members.**Implementation**@@ -214,27 +213,27 @@ Under `/api/metalakes/{metalake}`, following Gravitino conventions: `?details=`| Operation | Endpoint | Request → response || :----------------------- | :---------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------- || List | `GET /domains?details=false` | → `NameListResponse` / `DomainListResponse` |-| Create | `POST /domains` | `DomainCreateRequest{name, comment, properties, backingTag{name, value, create}, parent}` → `DomainResponse` |+| Create | `POST /domains` | `DomainCreateRequest{name, comment, properties, backingTag{name, create}, parent}` → `DomainResponse` || Get | `GET /domains/{domain}` | → `DomainResponse` || Alter | `PUT /domains/{domain}` | `DomainUpdatesRequest{updates: [rename, updateComment, setProperty, removeProperty]}` → `DomainResponse` || Publish / unpublish | `PATCH /domains/{domain}` | `DomainSetRequest{status}` → `DomainResponse` || Drop | `DELETE /domains/{domain}` | → `DropResponse` (`false` if absent) || Attach / move | `PUT /domains/{domain}/parent` | `DomainParentSetRequest{parent}` → `DomainResponse` || Detach | `DELETE /domains/{domain}/parent` | → `DomainResponse` (no-op for a top-level domain) |-| Set / remove backing tag | `PUT /domains/{domain}/backingTag` | `DomainBackingTagSetRequest{backingTag{name, value}}` (null `backingTag` removes it) → `DomainResponse` |+| Set / remove backing tag | `PUT /domains/{domain}/backingTag` | `DomainBackingTagSetRequest{backingTag{name}}` (null `backingTag` removes it) → `DomainResponse` || List subdomains | `GET /domains/{domain}/subdomains?details=false` | → `NameListResponse` / `DomainListResponse` || List members | `GET /domains/{domain}/objects` | → `DomainMemberListResponse` || Domains of an object | `GET /objects/{type}/{fullName}/domains?details=false` (leaf types only) | → `NameListResponse` / `DomainListResponse` || Add / remove members | Existing `POST /objects/{type}/{fullName}/tags` with the domain's backing tag | `TagValuesAssociateRequest` (v2) or `TagsAssociateRequest` (v1) |```-DomainDTO { name, comment, properties, status, parent, backingTag{name, value}, audit,+DomainDTO { name, comment, properties, status, parent, backingTag{name}, audit,relations? } // [{relation, source?}], only on domains of an objectDomainMemberDTO { object: MetadataObjectDTO, relations: [{relation, source?}] }```-- **Create**: `backingTag.create = true` creates a new tag with the given name (no `value`); `false` binds the existing (tag, value). Domain, new tag and parent edge are written in one transaction; on any failure nothing is created, and no new tag is left behind.-- **Membership requests**: adding a member with a value needs the v2 `TagValuesAssociateRequest` (`Content-Type: application/vnd.gravitino.v2+json`), which carries (name, value) pairs. Removing a tag by name with the v1 `TagsAssociateRequest` removes all its values on the object. The Java and Python clients already support both.+- **Create**: `backingTag.create = true` creates a new tag with the given name; `false` binds the existing tag. Domain, new tag and parent edge are written in one transaction; on any failure nothing is created, and no new tag is left behind.+- **Membership requests**: a member is added by assigning the backing tag. A valueless assignment, when the tag permits it, works with the v1 `TagsAssociateRequest` or the v2 `TagValuesAssociateRequest`; a tag with an allowed-values list must be assigned one of its allowed values with the v2 `TagValuesAssociateRequest`, since v1 accepts only tag names. Removing a tag by name with the v1 `TagsAssociateRequest` removes all its values on the object. The Java and Python clients already support both.- **Parent endpoints** address the child only, matching `Domain#attachToParent` and `Domain#detachFromParent`; detaching needs no parent name.- **State changes return the domain**: publish, unpublish, attach, move, detach and backing-tag changes return the updated domain, because the Java API returns a new `Domain` snapshot from them.- **Concurrency**: changes apply to the current state on the server and the last write wins, as for other Gravitino metadata operations; there is no version check. Detach removes the current parent edge and removing the backing tag removes the current one, whatever the caller's snapshot shows; detaching a top-level domain is a no-op, not an error. Domains are addressed by name, so if a domain is renamed and a new one takes its old name, later calls with that name act on the new domain.@@ -247,13 +246,13 @@ DomainMemberDTO { object: MetadataObjectDTO, relations: [{relation, source?}] }- **Errors**:- 404: `NoSuchDomainException` (missing, or a `DRAFT` domain the caller cannot see); `NoSuchTagException` (a backing tag to bind that does not exist).- 409: `DomainAlreadyExistsException` (create, or rename to an existing name); `NonEmptyDomainException` (drop with subdomains); `TagAlreadyExistsException` (a new backing tag whose name exists); `BackingTagAlreadyBoundException` (a binding that conflicts with another domain).- - 400: `IllegalArgumentException` (C1–C6, status consistency, a value the tag does not allow, a create request without a backing tag or with both `create` and a value, a `DOMAIN` target on the generic tag association API).+ - 400: `IllegalArgumentException` (C1–C6, status consistency, a create request without a backing tag, a `DOMAIN` target on the generic tag association API).- 403: `ForbiddenException` (binding a tag the caller does not own, nor the metalake; creating a new tag without `CREATE_TAG`).- **Encoding**: tag and domain names may contain `/`, which must be URL-encoded (`%2F`) in every path segment: `{tag}`, and `{domain}` in `/domains/{domain}`, `/objects/domain/{domain}/...`, `/owners/domain/{domain}` and `/permissions/roles/{role}/domain/{domain}/grant|revoke`. The Java, Python and MCP clients already encode path segments, and Gravitino's Jetty 9.4 / Jersey stack decodes them into the path parameters. An end-to-end test through the real server, with authentication and authorization enabled, will cover these paths, including filters that read the decoded path. Deployments behind a reverse proxy must pass `%2F` through without decoding it (for example, nginx `proxy_pass` without a URI part), and a later Jetty upgrade must keep ambiguous path separators allowed.- **Reused**: owners at `/owners/domain/{domain}`; privileges through the role and permission APIs, with `DOMAIN` as a securable type.- **Clients** (Java, Python) mirror the tag clients:- `DomainOperations` on `GravitinoMetalake`: list, get, `createDomain` (top-level domains only, with an explicit backing tag), alter and delete.- - On a `Domain`, each returning a new `Domain` snapshot: `publish()`, `unpublish()`, `attachToParent(parent)` (attach or move), `detachFromParent()`, and `updateBackingTag(TagValue)` (`null` removes it; maps to `PUT /domains/{domain}/backingTag`). Also on a `Domain`: `createSubdomain(...)` (with an explicit backing tag), `listSubdomains()` / `listSubdomainsInfo()` and `listMembers(DomainMemberFilter)`.+ - On a `Domain`, each returning a new `Domain` snapshot: `publish()`, `unpublish()`, `attachToParent(parent)` (attach or move), `detachFromParent()`, and `updateBackingTag(String)` (`null` removes it; maps to `PUT /domains/{domain}/backingTag`). Also on a `Domain`: `createSubdomain(...)` (with an explicit backing tag), `listSubdomains()` / `listSubdomainsInfo()` and `listMembers(DomainMemberFilter)`.- `SupportsDomains` (`listDomains()`, `listDomainsInfo()`) on tables, views, filesets, topics, models and semantic models; not on catalogs, schemas, columns or functions.- **Not included**: a batch lookup of the domains of many objects.@@ -268,7 +267,7 @@ A new read-only `domain` tool category in `mcp-server/`, added to `SUPPORTED_TOO| `list_domain_members` | `GET /domains/{domain}/objects`, with `domains` (a list of scopes to include, the domain itself or its subdomains; default the whole scope), `types`, `name_contains`, and `expand`; lets an agent look within a domain by type and name || `list_domains_for_metadata` | `GET /objects/{type}/{fullName}/domains`, for leaf objects |-Adding members uses the existing `associate_tag_with_metadata` tool. It keeps removing tags by name (v1, all values) and is extended to accept (name, value) pairs and send the v2 request, so value-backed domains work. The MCP server forwards the caller's `Authorization` header, so the server's visibility rules apply; with OAuth client-credentials, the agent sees what that service identity sees.+Adding members uses the existing `associate_tag_with_metadata` tool. It keeps removing tags by name (v1, all values) and is extended to accept (name, value) pairs and send the v2 request. The MCP server forwards the caller's `Authorization` header, so the server's visibility rules apply; with OAuth client-credentials, the agent sees what that service identity sees.### Events and auditdiff --git a/docs/domains.md b/docs/domains.mdindex 27248b83a1..25ee27ab1d 100644--- a/docs/domains.md+++ b/docs/domains.md@@ -26,7 +26,8 @@ a parent cannot be unpublished while a child is published. See the## Membership through tags-A domain explicitly binds a backing tag, optionally with one value. Membership is derived from+Each domain explicitly binds its own backing tag, and a tag backs at most one domain. Membership+depends only on the presence of that tag and is derived fromexisting [tag assignments and inheritance](./tags.md), rather than maintained in a separate list.Use the [tag API](./manage-tags-in-gravitino.md) to assign/remove a backing tag on a leaf, schema orcatalog. There is no Domain add-member or remove-member API.@@ -44,23 +45,19 @@ A member query has two modes:absent.Clients identify a member that includes its children by its `catalog` or `schema` type. Such a-member stands for the objects under it, except those where a nearer assignment of the same tag-overrides it as described below; use `expand=true` or object-to-domain lookup to resolve them.+member stands for the leaves under it that inherit the tag; use `expand=true` or object-to-domain+lookup to resolve them.-For the same tag, the assignment nearest the leaf wins: leaf before schema before catalog.-Assignments are replaced as a whole at each nearer level, not combined with ancestor values.-For example, `department=hr` on a table masks `department=finance` on its schema, so the table does-not belong to the domain backed by `department=finance`. A binding without a value matches any-effective assignment of that tag; a valued binding tests exact, case-sensitive containment in the-assignment's values. Different tags resolve independently, allowing membership in multiple domains.+A leaf is a member when it carries the backing tag directly or inherits it from its schema or+catalog. Membership uses only the presence of the tag, and any value on an assignment is ignored.+The assignment itself follows the tag's constraint: a tag with an allowed-values list must be assigned+one of its allowed values with the v2 tag-value API. To remove a backing tag from an object, remove it by name with the v1 tag+API, which clears all its direct assignments on the object whatever their values.+Different tags resolve independently, allowing membership in multiple domains.Removing a tag from a leaf changes only its own assignment; it is not an opt-out from inheritance.If its schema or catalog still assigns that backing tag, the leaf remains a member through-inheritance. Removing the last directly assigned value can also reveal an ancestor assignment and-move the leaf back into a different valued domain. To remove inherited membership, change the-assignment at its source or use a nearer assignment that does not match the valued binding.-A valueless backing-tag binding matches any assignment of that tag, so assigning another value-cannot exclude the leaf from that domain.+inheritance. To remove inherited membership, remove the assignment at its source.## Relations and sourcesdiff --git a/docs/manage-domains-in-gravitino.md b/docs/manage-domains-in-gravitino.mdindex 2d0baf42f7..04a4d51c40 100644--- a/docs/manage-domains-in-gravitino.md+++ b/docs/manage-domains-in-gravitino.md@@ -41,7 +41,8 @@ named `test`, with clients connected to that metalake. Java uses `lake` (`GravitPython uses `lake` (`GravitinoClient`). `domain` refers to a loaded Finance domain. Import JavaDomain types from `org.apache.gravitino.domain`, `TagValue` from `org.apache.gravitino.tag`, and`MetadataObject` from `org.apache.gravitino`. Python uses `gravitino.api.domain`,-`gravitino.api.tag` and `gravitino.api.metadata_object` respectively.+`gravitino.api.tag` and `gravitino.api.metadata_object` respectively. Domain APIs take the backing+tag as a tag name.REST examples use simple authentication as the configured administrator `anonymous`.These are independent operation examples; the [complete examples](#complete-java-example) belowshow a runnable sequence with setup and cleanup.@@ -74,14 +75,14 @@ curl --fail-with-body -u anonymous:dummy -X POST -H 'Content-Type: application/j```javaDomain domain = lake.createDomain("Finance", "Financial assets", Collections.emptyMap(),- TagValue.noValue("finance"), true);+ "finance", true);```</TabItem><TabItem value="python" label="Python">```python-domain = lake.create_domain("Finance", "Financial assets", {}, TagValue("finance"), True)+domain = lake.create_domain("Finance", "Financial assets", {}, "finance", True)```</TabItem>@@ -334,14 +335,14 @@ curl --fail-with-body -u anonymous:dummy -X POST -H 'Content-Type: application/j```javaDomain child = domain.createSubdomain(- "Planning_US", null, null, TagValue.noValue("planning"), true);+ "Planning_US", null, null, "planning", true);```</TabItem><TabItem value="python" label="Python">```python-child = domain.create_subdomain("Planning_US", None, None, TagValue("planning"), True)+child = domain.create_subdomain("Planning_US", None, None, "planning", True)```</TabItem>@@ -478,26 +479,22 @@ Creation always requires an explicit backing tag:| Intent | Java | Python | REST `backingTag` || --- | --- | --- | --- |-| Create a new valueless tag | `TagValue.noValue("finance"), true` | `TagValue("finance"), True` | `{"name":"finance","create":true}` |-| Bind an existing tag, any assignment | `TagValue.noValue("department"), false` | `TagValue("department"), False` | `{"name":"department","create":false}` |-| Bind an existing tag value | `TagValue.of("department", "finance"), false` | `TagValue("department", "finance"), False` | `{"name":"department","value":"finance","create":false}` |+| Create a new valueless tag | `"finance", true` | `"finance", True` | `{"name":"finance","create":true}` |+| Bind an existing tag | `"finance_data", false` | `"finance_data", False` | `{"name":"finance_data","create":false}` |New backing tags allow no values and are owned by the creator. Creation never implicitly adopts an-existing tag: `create=true` with an existing name conflicts. Supplying a value with `create=true` is-invalid. For an existing tag, the value must satisfy its immutable allowed-values constraint. See-[Tag value constraints](./manage-tags-in-gravitino.md#create-a-tag-with-a-value-constraint).--A tag can back one domain without a value, or multiple domains with distinct values. A valueless-binding conflicts with every other binding of the same tag; two bindings of the same exact value-also conflict. Bindings with distinct values are allowed, even between a parent and its child.-A valueless binding matches every effective assignment of that tag, including assignments with values;-a valued binding matches when the effective assignment contains that exact, case-sensitive value.--`domain.updateBackingTag(TagValue.of("department", "finance"))` or Python-`domain.update_backing_tag(TagValue("department", "finance"))` replaces the binding with an existing-tag. Pass `null` / `None` to remove it. Repeating a binding is a no-op. Removing a binding does not-delete the tag, change assignments, or remove child membership roll-ups. Replacing it does not migrate-members: only effective assignments matching the new binding contribute the domain's own members.+existing tag: `create=true` with an existing name conflicts. Any existing tag can be bound, whatever+values it allows. Each domain has its own backing tag: a tag backs at most one domain, so binding a+tag that already backs another domain conflicts, even between a parent and its child.++Membership depends only on the presence of the backing tag. An object that carries the tag, with or+without values, matches; any value on an assignment is ignored.++`domain.updateBackingTag("finance_data")` or Python `domain.update_backing_tag("finance_data")`+replaces the binding with an existing tag. Pass `null` / `None` to remove it. Repeating a binding is+a no-op. Removing a binding does not delete the tag, change assignments, or remove child membership+roll-ups. Replacing it does not migrate members: only objects carrying the new tag contribute the+domain's own members.Bindings use tag identity (ID), not its name. Renaming a tag preserves membership and exposes the newtag name on a freshly loaded domain. Deleting it leaves the domain without a backing tag. Recreating@@ -506,8 +503,9 @@ Domain rename, move, detach and deletion never rename or delete its backing tag.### Create a Domain with an Existing Backing Tag-Assume `department` already exists and allows the value `finance`. Bind it explicitly with-`create=false`; omit the value to match any effective assignment of that tag. Binding requires+Assume the tag `finance_data` already exists. Bind it explicitly with `create=false`; the tag can+be bound whatever values it allows, and objects carrying it are members whatever values their+assignments have. Binding requiresownership of the existing tag or metalake when authorization is enabled.<Tabs groupId='language' queryString>@@ -515,7 +513,7 @@ ownership of the existing tag or metalake when authorization is enabled.```shellcurl --fail-with-body -u anonymous:dummy -X POST -H 'Content-Type: application/json' \- -d '{"name":"Finance","backingTag":{"name":"department","value":"finance","create":false}}' \+ -d '{"name":"Finance","backingTag":{"name":"finance_data","create":false}}' \"http://127.0.0.1:8090/api/metalakes/test/domains"```@@ -524,7 +522,7 @@ curl --fail-with-body -u anonymous:dummy -X POST -H 'Content-Type: application/j```javaDomain domain = lake.createDomain(- "Finance", null, null, TagValue.of("department", "finance"), false);+ "Finance", null, null, "finance_data", false);```</TabItem>@@ -532,7 +530,7 @@ Domain domain = lake.createDomain(```pythondomain = lake.create_domain(- "Finance", None, None, TagValue("department", "finance"), False+ "Finance", None, None, "finance_data", False)```@@ -541,7 +539,7 @@ domain = lake.create_domain(### Replace a Backing Tag-Bind an existing tag, optionally with a value. Members are not migrated and previous assignments+Bind an existing tag by name. Members are not migrated and previous assignmentsremain unchanged. Repeating the current binding is a no-op.<Tabs groupId='language' queryString>@@ -549,7 +547,7 @@ remain unchanged. Repeating the current binding is a no-op.```shellcurl --fail-with-body -u anonymous:dummy -X PUT -H 'Content-Type: application/json' \- -d '{"backingTag":{"name":"department","value":"finance"}}' \+ -d '{"backingTag":{"name":"finance_data"}}' \"http://127.0.0.1:8090/api/metalakes/test/domains/Finance/backingTag"```@@ -557,14 +555,14 @@ curl --fail-with-body -u anonymous:dummy -X PUT -H 'Content-Type: application/js<TabItem value="java" label="Java">```java-Domain updated = domain.updateBackingTag(TagValue.of("department", "finance"));+Domain updated = domain.updateBackingTag("finance_data");```</TabItem><TabItem value="python" label="Python">```python-updated = domain.update_backing_tag(TagValue("department", "finance"))+updated = domain.update_backing_tag("finance_data")```</TabItem>@@ -605,13 +603,17 @@ unbound = domain.update_backing_tag(None)Members are managed through the existing tag API. There is no separate Domain add/remove-memberendpoint. In the assignment examples, `model` is a loaded model named `models.sales.forecast` and-`department` is an existing tag allowing `finance`. See [tag operations](./manage-tags-in-gravitino.md)+`finance` is the backing tag of the Finance domain. See [tag operations](./manage-tags-in-gravitino.md)for creating constrained tags and assigning them to catalogs or schemas.### Assign a Backing Tag to an Object-Assign the Finance backing-tag value to the model using normal tag permissions. The same API-works for leaf, schema and catalog assignments. A tagged container and its directly tagged descendants+Assign the Finance backing tag to the model using normal tag permissions. The assignment follows the+tag's own constraint: the valueless examples below work for a tag without an allowed-values list, such+as one created with the domain. A tag with an allowed-values list must be assigned one of its allowed+values, for example `{"name":"finance","value":"risk"}` or `TagValue.of("finance", "risk")`. Domain+membership uses only the presence of the tag and ignores the value. The same API works for leaf,+schema and catalog assignments. A tagged container and its directly tagged descendantsappear separately. Use `expand=true` to include recorded leaves that inherit the binding.Tag-value requests use `application/vnd.gravitino.v2+json`; Domain endpoints use the v1 API.@@ -621,7 +623,7 @@ Tag-value requests use `application/vnd.gravitino.v2+json`; Domain endpoints use```shellcurl --fail-with-body -u anonymous:dummy -X POST -H 'Accept: application/vnd.gravitino.v2+json' \-H 'Content-Type: application/vnd.gravitino.v2+json' \- -d '{"tagsToAdd":[{"name":"department","value":"finance"}],"tagsToRemove":[]}' \+ -d '{"tagsToAdd":[{"name":"finance"}],"tagsToRemove":[]}' \"http://127.0.0.1:8090/api/metalakes/test/objects/model/models.sales.forecast/tags"```@@ -630,7 +632,7 @@ curl --fail-with-body -u anonymous:dummy -X POST -H 'Accept: application/vnd.gra```javamodel.supportsTags().associateTags(- new TagValue[] {TagValue.of("department", "finance")}, new TagValue[0]);+ new TagValue[] {TagValue.noValue("finance")}, new TagValue[0]);```</TabItem>@@ -638,7 +640,7 @@ model.supportsTags().associateTags(```pythonmodel.supports_tags().assign_tags(- tags_to_add=[{"name": "department", "value": "finance"}]+ tags_to_add=["finance"])```@@ -647,16 +649,19 @@ model.supports_tags().assign_tags(### Remove a Backing Tag Assignment-Remove the value assigned directly to the model. An ancestor assignment can then become-effective again, so this does not necessarily remove inherited Domain membership.+Remove the backing tag assigned directly to the model. Removing the tag by name with the v1 tag API+clears all its direct assignments on the object, with or without values. The v2 tag-value API removes+only the given pair, so an object that keeps another value of the tag remains a member. An ancestor+assignment can then become effective again, so this does not necessarily remove inherited Domain+membership.<Tabs groupId='language' queryString><TabItem value="shell" label="REST">```shell-curl --fail-with-body -u anonymous:dummy -X POST -H 'Accept: application/vnd.gravitino.v2+json' \- -H 'Content-Type: application/vnd.gravitino.v2+json' \- -d '{"tagsToAdd":[],"tagsToRemove":[{"name":"department","value":"finance"}]}' \+curl --fail-with-body -u anonymous:dummy -X POST -H 'Accept: application/vnd.gravitino.v1+json' \+ -H 'Content-Type: application/json' \+ -d '{"tagsToRemove":["finance"]}' \"http://127.0.0.1:8090/api/metalakes/test/objects/model/models.sales.forecast/tags"```@@ -664,17 +669,14 @@ curl --fail-with-body -u anonymous:dummy -X POST -H 'Accept: application/vnd.gra<TabItem value="java" label="Java">```java-model.supportsTags().associateTags(- new TagValue[0], new TagValue[] {TagValue.of("department", "finance")});+model.supportsTags().associateTags(new String[0], new String[] {"finance"});```</TabItem><TabItem value="python" label="Python">```python-model.supports_tags().assign_tags(- tags_to_remove=[{"name": "department", "value": "finance"}]-)+model.supports_tags().associate_tags([], ["finance"])```</TabItem>@@ -868,7 +870,6 @@ import org.apache.gravitino.domain.DomainMember;import org.apache.gravitino.domain.DomainMemberFilter;import org.apache.gravitino.domain.DomainRelation;import org.apache.gravitino.model.Model;-import org.apache.gravitino.tag.TagValue;/** Demonstrates Domain discovery and cleanup on a local Gravitino server. */public class DomainExample {@@ -886,9 +887,9 @@ public class DomainExample {Model model = catalog.asModelCatalog().registerModel(NameIdentifier.of("sales", "forecast"), "", Collections.emptyMap());Domain draft = lake.createDomain(- "Finance", "Financial assets", Collections.emptyMap(), TagValue.noValue("finance"), true);+ "Finance", "Financial assets", Collections.emptyMap(), "finance", true);Domain child = draft.createSubdomain(- "Planning_US", null, null, TagValue.noValue("planning"), true);+ "Planning_US", null, null, "planning", true);model.supportsTags().associateTags(new String[] {"planning"}, new String[0]);Domain published = draft.publish();child = child.publish();@@ -940,7 +941,6 @@ import uuidfrom gravitino import Catalog, GravitinoAdminClient, GravitinoClient, NameIdentifierfrom gravitino.api.domain import Domain, DomainMemberFilter, DomainRelation-from gravitino.api.tag import TagValuefrom gravitino.auth.simple_auth_provider import SimpleAuthProvideros.environ["GRAVITINO_USER"] = "anonymous"@@ -958,8 +958,8 @@ try:model = catalog.as_model_catalog().register_model(NameIdentifier.of("sales", "forecast"), "", {})- draft = lake.create_domain("Finance", "Financial assets", {}, TagValue("finance"), True)- child = draft.create_subdomain("Planning_US", None, None, TagValue("planning"), True)+ draft = lake.create_domain("Finance", "Financial assets", {}, "finance", True)+ child = draft.create_subdomain("Planning_US", None, None, "planning", True)model.supports_tags().associate_tags(["planning"], [])published = draft.publish()child = child.publish()@@ -1003,10 +1003,10 @@ Encode metadata path parameters individually and supply query values with `--dat| HTTP status | Typical Domain behavior || --- | --- || 200 | Success with `code: 0`; empty queries return empty arrays; deleting an absent domain returns `dropped: false`. |-| 400 | Invalid request: invalid domain names or filters, unsupported member types, illegal hierarchy/status transition, disallowed tag value, or a value supplied while creating a new backing tag. |+| 400 | Invalid request: invalid domain names or filters, unsupported member types, or illegal hierarchy/status transition. || 403 | Insufficient permission on a published domain, a required backing tag, or a reverse-lookup object. || 404 | Missing metalake/domain/parent/tag/object, or a draft hidden from the caller. |-| 409 | Duplicate domain/tag name, backing-tag binding conflict, deleting a parent with children, disabled metalake, or an optimistic lock conflict during domain alteration or deletion. |+| 409 | Duplicate domain/tag name, a tag that already backs another domain, deleting a parent with children, disabled metalake, or an optimistic lock conflict during domain alteration or deletion. || 415 | Unsupported request Content-Type; the error response uses `application/json`. || 5xx | Server failure; inspect the error response and server log. |diff --git a/docs/open-api/domains.yaml b/docs/open-api/domains.yamlindex e35a5f02dd..90dd2c9ad7 100644--- a/docs/open-api/domains.yaml+++ b/docs/open-api/domains.yaml@@ -69,7 +69,7 @@ paths:summary: Create a domainoperationId: createDomaindescription: >-- Creates a DRAFT domain, its optional parent edge and an optional new backing tag atomically. A failure leaves no new domain or tag behind. Requires MANAGE_DOMAIN on the metalake and, when specified, the parent. The backing tag must be explicit: create=true never adopts an existing tag and cannot include a value. Bindings use tag identity, so tag rename preserves a binding while delete/recreate does not. A tag can back one domain without a value, or multiple domains with distinct exact values; these forms cannot be mixed. A new tag additionally requires CREATE_TAG on the metalake; an existing tag requires ownership of that tag or the metalake. Hidden drafts return 404; other permission failures return 403.+ Creates a DRAFT domain, its optional parent edge and an optional new backing tag atomically. A failure leaves no new domain or tag behind. Requires MANAGE_DOMAIN on the metalake and, when specified, the parent. The backing tag must be explicit: create=true creates a new valueless tag and never adopts an existing tag; create=false binds an existing tag whatever values it allows. Bindings use tag identity, so tag rename preserves a binding while delete/recreate does not. A tag backs at most one domain. Membership depends only on the presence of the tag; any value on an assignment is ignored. A new tag additionally requires CREATE_TAG on the metalake; an existing tag requires ownership of that tag or the metalake. Hidden drafts return 404; other permission failures return 403.requestBody:required: truecontent:@@ -367,7 +367,7 @@ paths:summary: Set or remove the backing tagoperationId: setDomainBackingTagdescription: >-- Binds an existing tag with an optional exact value, or removes the binding when backingTag is null. Members are not migrated; previous tag assignments remain unchanged. Requires MANAGE_DOMAIN on the domain, inherited from its current parent or the metalake. Binding a tag additionally requires ownership of that tag or the metalake; removing a binding needs no tag privilege. Hidden drafts return 404; other permission failures return 403.+ Binds an existing tag by name, whatever values it allows, or removes the binding when backingTag is null. A tag backs at most one domain. Members are not migrated; previous tag assignments remain unchanged. Requires MANAGE_DOMAIN on the domain, inherited from its current parent or the metalake. Binding a tag additionally requires ownership of that tag or the metalake; removing a binding needs no tag privilege. Hidden drafts return 404; other permission failures return 403.requestBody:required: truecontent:@@ -732,10 +732,7 @@ components:properties:name:type: string- value:- type: string- nullable: true- description: Null matches any effective assignment of this tag, including valueless assignments.+ description: The name of the backing tag. Objects that carry the tag are members whatever values the assignment has.audit:$ref: "./openapi.yaml#/components/schemas/Audit"relations:@@ -831,16 +828,16 @@ components:BackingTag:type: objectrequired: [name]+ additionalProperties: falseproperties:name:type: stringminLength: 1- value:- type: string- nullable: true- minLength: 1- maxLength: 256- description: Exact assignment value; null binds any effective assignment of the tag.+ description: The name of the backing tag.+ create:+ type: boolean+ default: false+ description: True creates a new valueless tag. False binds an existing tag, whatever values it allows.DomainName:type: string@@ -874,19 +871,11 @@ components:enum: [null]description: Optional top-level parent. A subdomain is created atomically under it.backingTag:- allOf:- - $ref: "#/components/schemas/BackingTag"- - type: object- properties:- create:- type: boolean- default: false- description: True creates a new valueless tag; value must be null or omitted. False binds an existing tag.+ $ref: "#/components/schemas/BackingTag"example:name: FinancebackingTag:- name: department- value: finance+ name: financecreate: falseDomainSetRequest:@@ -917,16 +906,12 @@ components:type: objectnullable: truerequired: [name]+ additionalProperties: falseproperties:name:type: stringminLength: 1- value:- type: string- nullable: true- minLength: 1- maxLength: 256- description: Exact assignment value; null binds any effective assignment of the tag.+ description: The name of the existing tag to bind.DomainUpdatesRequest:type: objectdiff --git a/mcp-server/mcp_server/client/domain_operation.py b/mcp-server/mcp_server/client/domain_operation.pyindex d4ed2c2ada..22f13cbf38 100644--- a/mcp-server/mcp_server/client/domain_operation.py+++ b/mcp-server/mcp_server/client/domain_operation.py@@ -48,10 +48,10 @@ class DomainOperation(ABC):"""List domain members and all applicable relations.By default, lists objects directly assigned the backing tag of the domain- or a visible subdomain. A tagged catalog or schema appears once. A nearer- assignment of the same tag can override the inherited value and exclude a- descendant. Set expand=true to list accessible recorded leaves whose- effective tags match, with INHERITED relations where applicable.+ or a visible subdomain. A tagged catalog or schema appears once. Any value+ on an assignment of the backing tag is ignored. Set expand=true to list+ accessible recorded leaves whose effective tags match, with INHERITED+ relations where applicable.types filters object types (for example TABLE, TOPIC, CATALOG or SCHEMA;CATALOG and SCHEMA are not allowed with expand=true).domains filters source domain names. name_contains matches a case-insensitivediff --git a/mcp-server/mcp_server/tools/domain.py b/mcp-server/mcp_server/tools/domain.pyindex a5f0ce377e..e8cd084e4f 100644--- a/mcp-server/mcp_server/tools/domain.py+++ b/mcp-server/mcp_server/tools/domain.py@@ -88,10 +88,10 @@ def load_domain_tools(mcp: FastMCP):"""List domain members and all applicable relations.By default, lists objects directly assigned the backing tag of the domain- or a visible subdomain. A tagged catalog or schema appears once. A nearer- assignment of the same tag can override the inherited value and exclude a- descendant. Set expand=true to list accessible recorded leaves whose- effective tags match, with INHERITED relations where applicable.+ or a visible subdomain. A tagged catalog or schema appears once. Any value+ on an assignment of the backing tag is ignored. Set expand=true to list+ accessible recorded leaves whose effective tags match, with INHERITED+ relations where applicable.types filters object types (for example TABLE, TOPIC, CATALOG or SCHEMA;CATALOG and SCHEMA are not allowed with expand=true).domains filters source domain names. name_contains matches a case-insensitivediff --git a/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.java b/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.javaindex bdb63baf9b..d67a7874bc 100644--- a/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.java+++ b/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.java@@ -62,6 +62,7 @@ import org.apache.gravitino.server.authorization.DomainAuthzHelper;import org.apache.gravitino.server.authorization.annotations.AuthorizationExpression;import org.apache.gravitino.server.authorization.annotations.AuthorizationMetadata;import org.apache.gravitino.server.web.Utils;+import org.apache.gravitino.tag.TagValue;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -170,7 +171,7 @@ public class DomainOperations {request.getName(),request.getComment(),request.getProperties(),- tag.tagValue(),+ TagValue.noValue(tag.getName()),tag.isCreate()): checked.createSubdomain(metalake,@@ -178,7 +179,7 @@ public class DomainOperations {request.getName(),request.getComment(),request.getProperties(),- tag.tagValue(),+ TagValue.noValue(tag.getName()),tag.isCreate());return domainResponse(created);});@@ -422,7 +423,9 @@ public class DomainOperations {.updateBackingTag(metalake,domain,- request.getBackingTag() == null ? null : request.getBackingTag().tagValue()));+ request.getBackingTag() == null+ ? null+ : TagValue.noValue(request.getBackingTag().getName())));});}@@ -476,7 +479,7 @@ public class DomainOperations {domain.properties(),domain.status(),domain.parent().orElse(null),- domain.backingTag().orElse(null),+ domain.backingTag().map(TagValue::name).orElse(null),DTOConverters.toDTO(domain.auditInfo()),domain.relations());}diff --git a/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainMembershipOperations.java b/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainMembershipOperations.javaindex 2affe6b941..0ac98db009 100644--- a/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainMembershipOperations.java+++ b/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainMembershipOperations.java@@ -333,7 +333,6 @@ public class TestDomainMembershipOperations extends BaseOperationsTest {assertEquals(Domain.Status.DRAFT, dto.getStatus());assertEquals("Finance", dto.getParent());assertEquals("department", dto.getBackingTag().getName());- assertEquals("tax", dto.getBackingTag().getValue());assertEquals("user", dto.getAudit().creator());assertEquals(DomainRelation.Type.DIRECT, dto.getRelations()[0].getRelation());}diff --git a/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainOperations.java b/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainOperations.javaindex 04df307381..294460dfee 100644--- a/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainOperations.java+++ b/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainOperations.java@@ -188,20 +188,20 @@ public class TestDomainOperations extends BaseOperationsTest {}@Test- public void testCreateSubdomainWithExistingValuedTag() {+ public void testCreateSubdomainWithExistingTag() {when(dispatcher.createSubdomain(- "test", "Parent", "Finance", null, null, TagValue.of("department", "finance"), false))+ "test", "Parent", "Finance", null, null, TagValue.noValue("department"), false)).thenReturn(domain(Domain.Status.DRAFT));try (Response response =send("POST",BASE,- "{\"name\":\"Finance\",\"parent\":\"Parent\",\"backingTag\":{\"name\":\"department\",\"value\":\"finance\"}}")) {+ "{\"name\":\"Finance\",\"parent\":\"Parent\",\"backingTag\":{\"name\":\"department\"}}")) {assertDomain(response, Domain.Status.DRAFT);}verify(dispatcher).createSubdomain(- "test", "Parent", "Finance", null, null, TagValue.of("department", "finance"), false);+ "test", "Parent", "Finance", null, null, TagValue.noValue("department"), false);}@Test@@ -257,10 +257,7 @@ public class TestDomainOperations extends BaseOperationsTest {assertDomain(response, Domain.Status.DRAFT);}try (Response response =- send(- "PUT",- ITEM + "/backingTag",- "{\"backingTag\":{\"name\":\"department\",\"value\":\"finance\"}}")) {+ send("PUT", ITEM + "/backingTag", "{\"backingTag\":{\"name\":\"department\"}}")) {assertDomain(response, Domain.Status.DRAFT);}try (Response response = send("PUT", ITEM + "/backingTag", "{\"backingTag\":null}")) {@@ -268,7 +265,7 @@ public class TestDomainOperations extends BaseOperationsTest {}verify(dispatcher).attachDomain("test", "Finance", "Parent");verify(dispatcher).detachDomain("test", "Finance");- verify(dispatcher).updateBackingTag("test", "Finance", TagValue.of("department", "finance"));+ verify(dispatcher).updateBackingTag("test", "Finance", TagValue.noValue("department"));verify(dispatcher).updateBackingTag("test", "Finance", null);}@@ -305,7 +302,8 @@ public class TestDomainOperations extends BaseOperationsTest {new String[] {"{}","{\"name\":\"Finance\"}",- "{\"name\":\"Finance\",\"backingTag\":{\"name\":\"t\",\"value\":\"v\",\"create\":true}}"+ "{\"name\":\"Finance\",\"backingTag\":{\"name\":\"t\",\"value\":\"v\",\"create\":true}}",+ "{\"name\":\"Finance\",\"backingTag\":{\"name\":\"t\",\"value\":\"v\"}}"}) {try (Response response = send("POST", BASE, json)) {assertError(response, 400);@@ -330,9 +328,13 @@ public class TestDomainOperations extends BaseOperationsTest {try (Response response = send("PUT", ITEM + "/parent", "{\"parent\":null}")) {assertError(response, 400);}- try (Response response =- send("PUT", ITEM + "/backingTag", "{\"backingTag\":{\"name\":\" \"}}")) {- assertError(response, 400);+ for (String json :+ new String[] {+ "{\"backingTag\":{\"name\":\" \"}}", "{\"backingTag\":{\"name\":\"t\",\"value\":\"v\"}}"+ }) {+ try (Response response = send("PUT", ITEM + "/backingTag", json)) {+ assertError(response, 400);+ }}verifyNoInteractions(dispatcher);}