OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

The ontology and the RDF writer have drifted apart — declared predicates aren't written, written predicates aren't declared

Open fmcardoso opened this issue 2 months ago • 4 comments

Part of the Ontology Studio EPIC. Found while working #32048.

What

openmetadata.ttl is treated as the contract for what can be queried out of the RDF store, but nothing tests it against the code that writes the store. The two have drifted, in both directions. All three instances below are verified against main @ 957d0c3fa5.

1. The writer emits a predicate the ontology does not declare

RdfRepository.buildLineageModel writes om:UPSTREAM — uppercase:

Property upstream = model.createProperty("https://open-metadata.org/ontology/", "UPSTREAM");
fromResource.addProperty(upstream, toResource);          // RdfRepository.java:839-840

The ontology declares om:upstream — lowercase (openmetadata.ttl:551), with

om:upstream a owl:ObjectProperty ;
    rdfs:subPropertyOf prov:wasDerivedFrom ;             # openmetadata.ttl:554

IRIs are case-sensitive, so …/ontology/UPSTREAM and …/ontology/upstream are unrelated names. Every axiom the ontology asserts about om:upstream describes a predicate that is never written. Turning on RDFS or OWL reasoning does nothing whatsoever for lineage edges — the subPropertyOf axiom has no data to apply to. The endpoint advertises inference=rdfs|owl|custom (RdfResource.querySparqlGet), so this is an advertised capability that silently no-ops.

2. The ontology declares a predicate the writer never emits

om:downstream a owl:ObjectProperty ;                     # openmetadata.ttl:559
    owl:inverseOf om:upstream .                          # openmetadata.ttl:562

No om:downstream triple is ever written. The code says so directly:

"OM does not store a separate om:DOWNSTREAM URI — downstream is derived by reading the same UPSTREAM edge from the other side." — RdfRepository.java:3451

Every shipped traversal does exactly that, with the inverse-path operator — (prov:wasDerivedFrom|^om:UPSTREAM)+ (RdfGraphService.java:138, :165).

That is a reasonable storage decision. The problem is that the ontology advertises om:downstream as available, so a query written from the .ttl — the documented contract — returns zero rows against a correctly populated store, with no error. The owl:inverseOf axiom would close the gap only under OWL reasoning, which defaults to off (inference=none, and RDF_INFERENCE_ENABLED defaults false).

3. An equivalence axiom that violates the vocabulary it borrows

om:upstream a owl:ObjectProperty ;
    owl:equivalentProperty dcat:qualifiedRelation ;      # openmetadata.ttl:555
    rdfs:range om:DataAsset .

DCAT 3 gives dcat:qualifiedRelation domain dcat:Resource and range dcat:Relationship — it links a resource to a reified relationship node, not directly to another dataset. Asserting equivalence with a DataAsset→DataAsset property is a range violation, and under OWL reasoning invites a reasoner to conclude that upstream tables are dcat:Relationship instances.

Lower severity than 1 and 2 — it only bites once reasoning is enabled — but it is the same root cause and should be fixed in the same pass. (#32670 is adjacent but distinct.)

Impact

#32048 is weighing whether native RDF querying should back search and answering. That case is materially weaker while the published ontology is not a reliable description of what is actually queryable — any query built from the .ttl may return nothing, or may miss inference the axioms appear to promise.

Done when

  • A test asserts, in both directions:
    • every predicate the writer emits is declared in openmetadata.ttl;
    • every predicate the ontology declares is either written by the projection, or explicitly annotated as inference-only / derived (e.g. om:downstream, which is intentionally read via an inverse path rather than stored).
  • The three instances above are resolved — casing unified, om:downstream either written or annotated, the dcat:qualifiedRelation equivalence corrected or dropped.
  • The test fails if someone adds a predicate to either side without the other.

fmcardoso avatar Sep 07 '26 14:09 fmcardoso

@fmcardoso, for #32883 a two-direction predicate inventory can catch this class of drift without assuming every declared property is physically stored. Classify each ontology predicate as stored, inverse/derived, or inference-only, and require a recorded query contract for the latter two. Compare the writer's emitted IRIs byte-for-byte against that inventory; normalizing case would conceal the reported defect.

A minimal fixture is two synthetic assets A and B with one lineage edge. With inference=none, assert the exact stored predicate and its reverse-path query; record explicitly whether a direct downstream query is supported or intentionally empty. With OWL enabled, assert the documented inverse behavior separately. Negative mutations: emit .../ontology/UPSTREAM while declaring .../ontology/upstream; add an undeclared writer predicate; add a declared property with neither writer coverage nor a derived/inference annotation. Each must fail with the specific unmatched IRI.

For the DCAT mapping, add a shape check that qualifiedRelation targets a relationship node, with the related asset behind the appropriate relationship structure; a direct asset target must not be treated as equivalent merely because both are resources. A maintainer should choose between removing that equivalence and implementing the qualified relationship projection. These are free proposed fixtures, not results from your RDF store. AI-assisted technical contribution, reviewed before sharing.

jankvacek-cell avatar Sep 08 '26 19:09 jankvacek-cell

Thanks — the drift you describe is being fixed in #32262 (open, not yet merged): every ontology term gets an om:projectionStatus annotation, contract tests enforce the inventory in both directions with your negative mutations included as named tests, and the lineage predicates are corrected there.

What may be missing is your third category. That PR ships two values, om:Stored and om:InferenceOnly, so "inverse/derived" has nowhere to go — and the result misleads. om:hasTypes is annotated om:InferenceOnly with the comment "there is no built-in derivation for this property", while carrying owl:inverseOf om:typeOf two lines below — a derivation that needs no reasoner at all. Same shape for om:composedOf / om:componentOf. Contrast om:creates, which is InferenceOnly and genuinely has no derivation. A third value, or your recorded query contract for anything not stored, would separate the two.

cc @harshach

fmcardoso avatar Sep 09 '26 08:09 fmcardoso

Thanks — the drift you describe is being fixed in #32262 (open, not yet merged): every ontology term gets an om:projectionStatus annotation, contract tests enforce the inventory in both directions with your negative mutations included as named tests, and the lineage predicates are corrected there.

What may be missing is your third category. That PR ships two values, om:Stored and om:InferenceOnly, so "inverse/derived" has nowhere to go — and the result misleads. om:hasTypes is annotated om:InferenceOnly with the comment "there is no built-in derivation for this property", while carrying owl:inverseOf om:typeOf two lines below — a derivation that needs no reasoner at all. Same shape for om:composedOf / om:componentOf. Contrast om:creates, which is InferenceOnly and genuinely has no derivation. A third value, or your recorded query contract for anything not stored, would separate the two.

cc @harshach

Thanks — yes, that’s exactly the distinction I was reaching for.

I’d lean toward making the three semantics explicit: Stored / Derived / InferenceOnly (or equivalent naming), rather than forcing consumers to infer “derived” from the surrounding ontology.

hasTypes is a good example: it isn’t stored, but it is deterministically obtainable via owl:inverseOf, which is materially different from something like creates where there is genuinely no derivation rule.

A recorded query contract could also solve it, but if projectionStatus is intended to be the inventory signal, a third value seems cleaner and easier to test mechanically.

Happy to extend the negative cases around that distinction if useful.

jankvacek-cell avatar Sep 09 '26 09:09 jankvacek-cell

Correction — I checked the ontology at the PR head and my example was wrong.

om:hasTypes is owl:inverseOf om:typeOf, but the projection writes neither: om:typeOf is InferenceOnly too. An inverse of something unwritten yields nothing, so the PR's "no built-in derivation" comment is accurate. Same for composedOf/componentOf and hasVersion/isVersionOf — both sides are InferenceOnly in each pair.

Across all 123 InferenceOnly terms, exactly one is derivable from a Stored one: om:UPSTREAM, via owl:inverseOf om:upstream. It is already owl:deprecated. So a third value would classify a single deprecated alias today — I'd leave the two as they are.

On the negative cases: two of your three are covered by named tests in #32262 — addingAPredicateToTheWriterWithoutAnOntologyDeclarationFails (which drops the declaration rather than adding a writer predicate, but asserts the same end state) and addingAnOntologyPropertyWithoutAProjectionFails. Both fail with the unmatched IRI named, as you asked. The case mutation isn't its own test, but everyWrittenPredicateIsDeclared compares IRIs as exact strings, so emitting .../UPSTREAM against a declared .../upstream does fail it. And the DCAT point went the first way you offered — owl:equivalentProperty dcat:qualifiedRelation is gone.

cc @harshach

fmcardoso avatar Sep 09 '26 17:09 fmcardoso