Skip to content

[#13877] feat(api): Add Domain API - #13881

Open
jerryshao wants to merge 17 commits into
apache:branch-domain-devfrom
jerryshao:13877-domain-api
Open

jerryshao wants to merge 17 commits into
apache:branch-domain-devfrom
jerryshao:13877-domain-api

Conversation

@jerryshao

@jerryshao jerryshao commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add the public Domain API, following the Domain design in #13867 (design doc v1.24, still in review):

  • org.apache.gravitino.domain:
    • Domain: name, comment, properties, Status (DRAFT / PUBLISHED), parent, backing tag (TagValue), and relations for domains of an object. Operations on a single domain live on the object:
      • publish(), unpublish(), attachToParent(parent) (attach or move), detachFromParent() and updateBackingTag(TagValue) (null removes it), each returning a new snapshot.
      • createSubdomain (with an explicit backing tag), listSubdomains / listSubdomainsInfo and listMembers(DomainMemberFilter).
    • DomainOperations for the metalake: list, get, create (top-level, with an explicit backing tag: a new tag to create or an existing (tag, value)), alter, delete.
    • DomainChange: rename, updateComment, setProperty, removeProperty.
    • SupportsDomains: list every visible domain whose scope contains a leaf object, with its relations. It is read-only; objects join or leave a domain through SupportsTags with the domain's backing tag.
    • DomainRelation: how an object relates to a domain (DIRECT, INHERITED from a catalog or schema, VIA_SUBDOMAIN), reported for members and for domains of an object.
    • DomainMember, with SUPPORTED_TYPES: the leaf types table, view, fileset, topic, model and semantic model. Catalogs and schemas are never members; a backing tag on them makes the leaf objects under them members.
    • DomainMemberFilter: types, nameContains, and domains, the domains whose scope is listed (the whole scope of the listed domain when not set).
  • supportsDomains() default accessors on Table, View, Fileset, Topic, Model and SemanticModel.
  • NoSuchDomainException, DomainAlreadyExistsException, NonEmptyDomainException (deleting a domain that has subdomains) and BackingTagAlreadyBoundException (a backing tag binding that conflicts with another domain).
  • MetadataObject.Type.DOMAIN as a single-level name type.
  • MetadataAuthzHelper now builds its metadata object entity types from MetadataObjectUtil.metadataObjectEntityTypes(). A type with no entity yet, such as DOMAIN, no longer breaks its static initialization.

Storage, REST endpoints, clients, MCP tools and authorization come in later subtasks. DOMAIN is not a taggable type; the backing tag is stored on the domain itself.

Why are the changes needed?

This is the first step of the Domain epic (#13864). It defines the public API that the core, server and client subtasks implement.

Fix: #13877

Does this PR introduce any user-facing change?

It adds a new public API in api/ and a new MetadataObject.Type.DOMAIN value. Nothing implements the API yet, so behavior does not change.

How was this patch tested?

  • New tests: TestDomainChange, TestDomainMemberFilter, TestDomainRelation, TestExceptions#testDomainExceptionsHierarchy, TestMetadataObjects#testDomainObject and TestMetadataObjectUtil#testMetadataObjectEntityTypes.
  • Commands run:
    • ./gradlew :api:build -PskipITs
    • ./gradlew compileTestJava -PskipITs for all modules
    • TestMetadataAuthzHelper in server-common
    • the core tag and garbage collector tests

🤖 Generated with Claude Code

jerryshao and others added 11 commits October 15, 2026 18:06
Add the public Domain API in the `org.apache.gravitino.domain` package,
following the Domain design (apache#13866), and `MetadataObject.Type.DOMAIN`
as a single-level name type.

MetadataAuthzHelper now collects the entity types of the metadata object
types that are backed by an entity, so a type without an entity yet,
such as DOMAIN, does not break its static initialization.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p Function support

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NonEmptyDomainException

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r#withDomains

Replace withIncludeAllSubdomains and withSubdomains with a single
withDomains option: the names of the listed domain and/or its
sub-domains the members come from, all of them when not set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…acks another domain

A domain name may contain "/". Instead, creating a domain with the
default backing tag fails when a tag with that name already backs
another domain, which also covers names left behind by moving or
renaming a domain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Document 403 for binding a backing tag the caller does not own, the
nearest-level rule for membership, the sub-domain reported for a member
that carries several backing tags, and an empty result when every name
given to withDomains is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jerryshao
jerryshao requested a review from mchades October 15, 2026 11:30
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Code Coverage Report

Overall Project 71.8% +0.03% 🟢
Files changed 77.56% 🟢

Module Coverage
aliyun 19.74% 🔴
api 55.39% +1.05% 🟢
authorization-common 85.96% 🟢
authorization-ranger 14.44% 🔴
aws 53.54% 🟢
aws-bundle 0.0% 🔴
azure 32.1% 🔴
azure-bundle 0.0% 🔴
catalog-common 29.49% 🔴
catalog-fileset 82.37% 🟢
catalog-glue 73.24% 🟢
catalog-hive 83.63% 🟢
catalog-jdbc-common 57.98% 🟢
catalog-jdbc-doris 87.56% 🟢
catalog-jdbc-mysql 81.91% 🟢
catalog-jdbc-postgresql 84.02% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 75.21% 🟢
catalog-lakehouse-generic 80.67% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 86.0% 🟢
catalog-lakehouse-paimon 84.36% 🟢
catalog-model 77.99% 🟢
cli 44.62% 🟢
client-java 79.34% 🟢
client-java-runtime 0.0% 🔴
common 60.49% 🟢
core 87.41% 🟢
filesystem-hadoop3 76.89% 🟢
flink 55.44% 🟢
flink-common 32.2% 🔴
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 62.3% 🟢
hive-metastore3-libs 58.8% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.53% 🟢
iceberg-rest-server 77.01% 🟢
idp-basic 86.77% 🟢
integration-test-common 0.0% 🔴
jobs 71.35% 🟢
k8s-job-executor 99.81% 🟢
lance-common 39.9% 🔴
lance-rest-server 69.51% 🟢
lineage 59.39% 🟢
optimizer 84.27% 🟢
optimizer-api 46.58% 🟢
server 91.43% 🟢
server-common 83.84% -0.49% 🟢
spark 61.79% 🟢
tencent 81.78% 🟢
tms 80.0% 🟢
trino-connector 63.31% 🟢
Files
Module File Coverage
api MetadataObject.java 100.0% 🟢
DomainMember.java 100.0% 🟢
DomainMemberFilter.java 95.0% 🟢
DomainRelation.java 92.86% 🟢
MetadataObjects.java 89.16% 🟢
DomainChange.java 88.89% 🟢
View.java 68.75% 🟢
BackingTagAlreadyBoundException.java 50.0% 🔴
DomainAlreadyExistsException.java 50.0% 🔴
NoSuchDomainException.java 50.0% 🔴
SemanticModel.java 25.0% 🔴
Domain.java 0.0% 🔴
DomainOperations.java 0.0% 🔴
SupportsDomains.java 0.0% 🔴
NonEmptyDomainException.java 0.0% 🔴
Fileset.java 0.0% 🔴
Topic.java 0.0% 🔴
Model.java 0.0% 🔴
Table.java 0.0% 🔴
core MetadataObjectUtil.java 87.77% 🟢
server-common MetadataAuthzHelper.java 76.44% 🟢

jerryshao and others added 6 commits October 15, 2026 20:54
Document that the parent name is returned even when the parent is not
visible, how a backing tag with or without a value matches tag
assignments, and that changes apply to the current state of the domain
with the last write winning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A name given to DomainMemberFilter#withDomains selects that domain's
scope: a top-level domain with its visible sub-domains, or a sub-domain
alone. Members of the listed domain itself are those whose
DomainMember#subdomain() is empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Following design v1.23, catalogs and schemas are never members: a
backing tag on them makes the leaf objects under it members, and
member listing expands them to those objects. DomainMember's supported
types become the leaf types, and a member's sub-domain is decided by
its effective tags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- createDomain and createSubdomain take an explicit backing tag and
  whether to create it; there is no default tag name or implicit
  adoption.
- Add BackingTagAlreadyBoundException for a binding that conflicts with
  another domain.
- Replace DomainMember#subdomain() and Domain#inheritedFrom() with
  DomainRelation (DIRECT, INHERITED, VIA_SUBDOMAIN with a source), listing
  every relation that applies.
- SupportsDomains is on leaf types only and lists every visible domain
  whose scope contains the object; drop it from Catalog and Schema.
- Document that privileges on a domain apply to its sub-domains, so
  moving or detaching changes access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Following design v1.25, the metalake, the current parent and the domain
are checked together: an owner of any of them passes, otherwise a
privilege must be allowed on one and denied on none, so a parent's allow
does not override a deny on the sub-domain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- SupportsDomains lists the parents of visible sub-domains only.
- DomainRelation#inherited keeps only the source's name and type, so
  relations built from any MetadataObject implementation compare equal.
- A member's relations are not narrowed by the filter's domains.
- Sub-domain listings return visible sub-domains; snapshot operations
  address the domain by name; MetadataObject.Type.DOMAIN describes leaf
  membership and that a domain cannot be tagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant