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

   ### What changes are proposed in this pull request?
   
   First slice of the ontology design in #14310: the API for a metalake-level 
`Ontology` and the converter
   to and from a standalone Apache Ossie ontology document. The metadata-store 
persistence is in #14368,
   and the REST endpoints, both clients and the user documentation are in 
#14365.
   
   **API** (`org.apache.gravitino.ontology`)
   
   - `Ontology`, a snapshot with name, comment, properties, `DRAFT`/`PUBLISHED` 
status and an immutable
     `OntologyDefinition`.
   - `OntologyDefinition` holds the concept graph: `OntologyConcept` components 
with a closed
     `ConceptType`, `OntologyRelationship` with required `verbalizes` phrasings 
and an optional
     `Multiplicity`, and `OntologyRole`.
   - `OntologyChange` and `OntologyOperations` for create, list, get, alter, 
delete and Ossie import and
     export.
   - `NoSuchOntologyException`, `OntologyAlreadyExistsException`, 
`IllegalOntologyException` and
     `NonEmptyOntologyException`.
   - `MetadataObject.Type.ONTOLOGY` as a metalake-level, one-level name, so 
owners and the ontology-specific
     privileges can target it.
   
   **Converter** (`OssieOntologyConverter` in `core`): validates the closed 
root, component, relationship and
   role property sets of `ontology/ontology.json`, maps the two concept types 
and two multiplicities,
   resolves QName IRIs against `prefixes`, and rejects embedded 
`ontology_mappings` with a message pointing
   at the standalone mapping document. Export re-imports the generated document 
before returning it.
   
   ### Why are the changes needed?
   
   Semantic Models hold metrics and joins but do not say what a concept means; 
Domains group assets but
   define no concepts. `Ontology` is the machine-readable half of that gap: an 
Ossie `ontology.json` concept
   graph that a glossary term can later reference and a query planner can 
resolve against (#14308).
   
   Two rules are enforced beyond the schema's keywords, because the document 
has no place for external
   references:
   
   - a relationship must carry at least one non-blank `verbalizes` phrasing, so 
every edge is expressible in
     language for an agent;
   - every concept named by `extends` or by a relationship role must be 
declared in the same document, so a
     dangling name is rejected at the boundary.
   
   The lifecycle is `DRAFT`/`PUBLISHED` and the privileges are 
`MANAGE_ONTOLOGY`/`USE_ONTOLOGY`, following
   Domain rather than the glossary's `DEFINITION` family, as settled in the 
design.
   
   Fixes #14367
   Part of #14309
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, additively: new public API types in `api/` and four new exceptions, and 
`MetadataObject.Type.ONTOLOGY`,
   which makes ontology a valid metadata object type for ownership and 
privileges.
   
   No metadata-store table, REST endpoint, configuration key or client method 
is added in this PR.
   
   ### How was this patch tested?
   
   The same suites as the stacked PR, restricted to the layers this one touches:
   
   ```
   JAVA_HOME=<jdk17> ./gradlew :api:test --tests 
"org.apache.gravitino.ontology.*" \
     :core:test --tests "org.apache.gravitino.ontology.*" \
                --tests "org.apache.gravitino.utils.TestMetadataObjectUtil" 
-PskipITs
   ```
   
   Note for reviewers: this branch also fixes a latent bug the new enum 
constant exposed.
   `MetadataAuthzHelper` mapped every `MetadataObject.Type.values()` entry to 
an entity type, so any metadata
   object type without an entity broke its static initializer. It now iterates 
the mapped types instead —
   which is what lets `ONTOLOGY` exist before its entity does.
   
   The `MetadataObject.java` / `MetadataObjects.java` / 
`MetadataObjectUtil.java` changes will conflict
   trivially with #13881, which lands the same kind of change for `DOMAIN` at 
the same places.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to