Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f83b7d7491 | |||
| 76e95de471 |
+899
-546
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+850
-213
File diff suppressed because it is too large
Load Diff
+337
-125
@@ -7,11 +7,113 @@
|
||||
@prefix pr: <https://ontology.pernod-ricard.com/metamodel/> .
|
||||
|
||||
#################################################################
|
||||
# PERNOD RICARD DATA META MODEL - T-Box v1.1
|
||||
# PERNOD RICARD DATA META MODEL - T-Box v1.5
|
||||
# Owner: Bastien Gourdon - Data Governance Office
|
||||
#
|
||||
# WHAT CHANGED vs v1.0
|
||||
# WHAT CHANGED vs v1.4
|
||||
# --------------------
|
||||
# CuratedObject -> DefinedObject, ObservedObject -> CapturedObject, in the
|
||||
# IRIs and not only in the labels. v1.4 renamed what screens showed and left
|
||||
# the terms themselves untouched, so the model said one thing and the
|
||||
# interface another -- exactly the split the short-label work was meant to
|
||||
# end. Every reference follows: subclass declarations, the disjointness
|
||||
# axiom, the shapes and their messages, and the prose in the comments.
|
||||
#
|
||||
# No instance changes. Nothing in the A-Box ever named these two classes
|
||||
# directly: an object reaches them through its layer, by entailment. The old
|
||||
# IRIs are kept deprecated per LC-002 so a domain file written against them
|
||||
# still classifies.
|
||||
#
|
||||
# WHAT CHANGED vs v1.3 (kept for reference)
|
||||
# -----------------------------------------
|
||||
# A. PhysicalRelation -> DataStructure. "Relation" meant a table in Codd's
|
||||
# sense, which reads as a property in an ontology and locks the class into
|
||||
# the tabular world. A Neo4j node label, a Mongo collection and a Kafka
|
||||
# topic are data structures; none of them is a relation. The class is also
|
||||
# the declared EXTENSION POINT for non-tabular storage -- see its comment
|
||||
# for the four lines that would insert Dataset and Graph beneath it.
|
||||
#
|
||||
# B. hasSource -> sourcedFrom, pointing at a System instead of holding a
|
||||
# string. "Which objects depend on MDM Product?" was unanswerable because
|
||||
# MDM Product was text. It also settles the naming collision the string
|
||||
# created with BIDataSource: one names a system, the other a BI surface,
|
||||
# and now they are different kinds of thing rather than two readings of
|
||||
# one property.
|
||||
#
|
||||
# C. storedIn serves two granularities, like represents before it:
|
||||
# DataObject storedIn DataStructure
|
||||
# DataElement storedIn Field
|
||||
# materializedAs is therefore redundant and deprecated. The seam between
|
||||
# what governance defines and what a harvester captures now counts ONE
|
||||
# relation instead of two.
|
||||
#
|
||||
# D. inSchema moves from DataStructure to nothing declared, and must stay
|
||||
# OPTIONAL in the shapes. Neo4j has no schema and BigQuery calls the level
|
||||
# a dataset; a minCount 1 would break on the first non-Snowflake harvest.
|
||||
#
|
||||
# WHAT CHANGED vs v1.2 (kept for reference)
|
||||
# -----------------------------------------
|
||||
# A. references -> qualifiedBy. "References" named the mechanism, a foreign
|
||||
# key; qualifiedBy names the reason: the Sell Out dataset is qualified by
|
||||
# Product, Customer, Currency and Date. It reads without explanation, and
|
||||
# it is what gives a fact its grain and its analysis context.
|
||||
#
|
||||
# B. primaryLocation, a SUB-PROPERTY of storedIn. One Data Element can sit in
|
||||
# several Fields, one authoritative and the others copies. Two parallel
|
||||
# properties would be free to disagree -- a field marked primary in one and
|
||||
# missing from the other. As a sub-property, entailment guarantees the
|
||||
# primary location is always among the locations. Primary/replica rather
|
||||
# than master/slave, which the industry has moved away from and which
|
||||
# reads badly to a business audience.
|
||||
#
|
||||
# C. hasShortLabel. rdfs:label carries the exhaustive name (Data Domain, Sell
|
||||
# Out Data Hub - Gold), hasShortLabel the one screens use (Domain, SODH
|
||||
# Gold). Same object was being called two things depending on where you
|
||||
# looked; now both names are declared and the viewers stop hard-coding a
|
||||
# display dictionary of their own.
|
||||
#
|
||||
# D. hasSource is now forbidden on a Business Object as well as on a Business
|
||||
# Concept. Same argument: a Business Object is a governance grouping, not
|
||||
# data. Its data lives in the Data Objects that represent it, and those
|
||||
# carry the system. In v0.6 the 15 objects carried a grab-bag -- physical
|
||||
# locations, migration notes, arbitration remarks -- under one property.
|
||||
#
|
||||
# WHAT CHANGED vs v1.1 (kept for reference)
|
||||
# -----------------------------------------
|
||||
# A. physicalizedIn -> storedIn. "Physicalized in" is jargon; the relation
|
||||
# says where the data sits, and "stored in" says that to anyone.
|
||||
#
|
||||
# B. hasSource MEANS ONE THING: the system that holds the authoritative data.
|
||||
# It was drifting into a third meaning on Business Concepts and Metrics,
|
||||
# where it named the DOCUMENT a record came from ("SODH back-doc v0.7").
|
||||
# A business concept has no data source -- it has an owning domain, which
|
||||
# is its authority, and a definition published in the glossary. The
|
||||
# property is now forbidden on concepts by SHACL.
|
||||
#
|
||||
# C. FIVE TERMS REMOVED OR DEPRECATED, none of them instantiated anywhere:
|
||||
# Table deleted -- deprecated since v1.0, replaced by
|
||||
# BaseTable, and never used. A deprecation that
|
||||
# never ends stops meaning anything.
|
||||
# constrainsRelation derivable: constrainsField -> livesIn gives the
|
||||
# relation. An asserted edge redundant with an
|
||||
# existing path is a future divergence.
|
||||
# MaterializedView a class standing in for an attribute; being
|
||||
# derived is what dependsOn already says.
|
||||
# approximateRowCount volumetry with no identified use. queryCount30d
|
||||
# and lastQueriedOn carry the rationalisation case.
|
||||
# hasVendor marginal.
|
||||
#
|
||||
# D. hasProductOwner drops from BLOCKING to a warning in the shapes. The SODH
|
||||
# product owner is genuinely not appointed yet, and a blocking rule that
|
||||
# cannot be satisfied truthfully forces invention -- the BR-004 lesson.
|
||||
#
|
||||
# Environment and deployedIn stay, unused. Without them a DEV table and its
|
||||
# PROD twin are indistinguishable and lineage pollutes silently on the first
|
||||
# multi-environment harvest. Unused because nothing is harvested yet, not
|
||||
# because they are useless.
|
||||
#
|
||||
# WHAT CHANGED vs v1.0 (kept for reference)
|
||||
# -----------------------------------------
|
||||
# A. RELATIONS SIMPLIFIED AND GIVEN HONEST NAMES
|
||||
# belongsToDomain + belongsToSubDomain -> belongsTo (one property,
|
||||
# scoped per class by SHACL; reusable if a domain family appears).
|
||||
@@ -69,7 +171,7 @@
|
||||
# one Product Owner: it is a consumable, and there must be no ambiguity
|
||||
# about who runs it.
|
||||
#
|
||||
# G. realizesMetric KEPT AS A TRANSITIONAL CONTROL
|
||||
# G. exposesMetric KEPT AS A TRANSITIONAL CONTROL
|
||||
# Declared, required on certified BI fields, and that is all. No rule is
|
||||
# written against the lineage chain: making the assertion conditional on
|
||||
# intermediate mappings existing would create confusion and discourage
|
||||
@@ -88,11 +190,11 @@
|
||||
# freeze the term namespace and version the ontology document.
|
||||
# MIGRATION: sed -i 's|/metamodel/0.9/|/metamodel/|g' instances/*.ttl
|
||||
#
|
||||
# 2. NEW ORTHOGONAL AXIS: CuratedObject vs ObservedObject.
|
||||
# 2. NEW ORTHOGONAL AXIS: DefinedObject vs CapturedObject.
|
||||
# LAYER says WHAT an object is. PROVENANCE says HOW IT GOT HERE.
|
||||
# - CuratedObject : asserted by governance, edited via pull request,
|
||||
# - DefinedObject : written by governance, edited via pull request,
|
||||
# subject to the full ownership shape.
|
||||
# - ObservedObject: harvested from a running system, rebuilt every night,
|
||||
# - CapturedObject: read from a running system, rebuilt every night,
|
||||
# NEVER hand-edited, NOT required to carry owningDomain.
|
||||
# Without this split, the SHACL ownership shape would demand an owning Data
|
||||
# Domain and a named owner on every one of the ~50 000 Snowflake columns.
|
||||
@@ -102,7 +204,7 @@
|
||||
# Transformation, plus column-level lineage (derivedFrom).
|
||||
#
|
||||
# 4. NEW CONSUMPTION LAYER (Tableau + Looker).
|
||||
# BIWorkspace / BIDataSource / BIField / BIReport, plus realizesMetric,
|
||||
# BIWorkspace / BIDataSource / BIField / BIReport, plus exposesMetric,
|
||||
# which closes the loop between a certified Metric and its actual
|
||||
# implementations in the BI estate.
|
||||
#
|
||||
@@ -117,13 +219,13 @@
|
||||
|
||||
<https://ontology.pernod-ricard.com/metamodel/>
|
||||
a owl:Ontology ;
|
||||
owl:versionIRI <https://ontology.pernod-ricard.com/metamodel/1.1> ;
|
||||
owl:priorVersion <https://ontology.pernod-ricard.com/metamodel/1.0> ;
|
||||
owl:versionIRI <https://ontology.pernod-ricard.com/metamodel/1.5> ;
|
||||
owl:priorVersion <https://ontology.pernod-ricard.com/metamodel/1.4> ;
|
||||
dcterms:title "Pernod Ricard Data Meta Model" ;
|
||||
dcterms:creator "Bastien Gourdon" ;
|
||||
dcterms:modified "2026-07-26"^^xsd:date ;
|
||||
owl:versionInfo "1.1.0-draft-2026-07-26" ;
|
||||
rdfs:comment """OWL T-Box. Six layers (Ownership, Business, Logical, Delivery, Physical, Consumption) crossed with a provenance axis (Curated vs Observed). Curated objects are asserted by governance and reviewed; Observed objects are harvested from Snowflake, Tableau and Looker and are rebuilt, never edited. Bridge annotation properties are declared for future alignment with domain ontologies.""" .
|
||||
dcterms:modified "2026-07-30"^^xsd:date ;
|
||||
owl:versionInfo "1.5.0-draft-2026-07-30" ;
|
||||
rdfs:comment """OWL T-Box. Six layers (Ownership, Business, Logical, Delivery, Physical, Consumption) crossed with a provenance axis (Defined vs Captured). Defined objects are written by governance and reviewed; Captured objects are read from Snowflake, Tableau and Looker and are rebuilt, never edited. Bridge annotation properties are declared for future alignment with domain ontologies.""" .
|
||||
|
||||
|
||||
#################################################################
|
||||
@@ -153,11 +255,11 @@ pr:denotesActivity a owl:AnnotationProperty ;
|
||||
# ---- Operational documentation --------------------------------
|
||||
pr:harvestSource a owl:AnnotationProperty ;
|
||||
rdfs:label "harvest source" ;
|
||||
rdfs:comment "For Observed terms: the system view or API that populates this term. Documents the contract between the meta model and the harvester." .
|
||||
rdfs:comment "For Captured terms: the system view or API that populates this term. Documents the contract between the meta model and the harvester." .
|
||||
|
||||
pr:curationMode a owl:AnnotationProperty ;
|
||||
rdfs:label "curation mode" ;
|
||||
rdfs:comment "ASSERTED (governance writes it), HARVESTED (a job writes it) or PROPOSED_CONFIRMED (a job proposes, a steward confirms)." .
|
||||
pr:authoringMode a owl:AnnotationProperty ;
|
||||
rdfs:label "authoring mode" ;
|
||||
rdfs:comment "Who writes this, in practice: ASSERTED (a person does), HARVESTED (a job does) or PROPOSED_CONFIRMED (a job proposes and a person accepts). Renamed from curationMode along with the classes: 'curation' belonged to the same jargon family as 'curated'." .
|
||||
|
||||
|
||||
#################################################################
|
||||
@@ -166,79 +268,106 @@ pr:curationMode a owl:AnnotationProperty ;
|
||||
|
||||
pr:MetaModelObject a owl:Class ;
|
||||
rdfs:label "Meta Model Object" ;
|
||||
rdfs:comment "Anything the meta model describes. Actors are deliberately NOT Meta Model Objects." .
|
||||
rdfs:comment "Anything the meta model describes. Actors are deliberately NOT Meta Model Objects." ;
|
||||
pr:hasShortLabel "Meta model object" .
|
||||
|
||||
pr:CuratedObject a owl:Class ; rdfs:subClassOf pr:MetaModelObject ;
|
||||
rdfs:label "Curated Object" ;
|
||||
pr:curationMode "ASSERTED" ;
|
||||
rdfs:comment "Asserted by governance, edited through pull request on the domain TTL file, subject to the full ownership and lifecycle shape (identifier, name, owner, owning Data Domain, status, version)." .
|
||||
pr:DefinedObject a owl:Class ; rdfs:subClassOf pr:MetaModelObject ;
|
||||
rdfs:label "Defined Object" ;
|
||||
pr:hasShortLabel "Defined" ;
|
||||
pr:authoringMode "ASSERTED" ;
|
||||
rdfs:comment "Somebody decided it. Written by governance, edited through a pull request on the domain TTL file, and subject to the full identity and lifecycle shape: identifier, name, owner, owning Data Domain, status, version." .
|
||||
|
||||
pr:ObservedObject a owl:Class ; rdfs:subClassOf pr:MetaModelObject ;
|
||||
rdfs:label "Observed Object" ;
|
||||
pr:curationMode "HARVESTED" ;
|
||||
rdfs:comment "Harvested from a running system and rebuilt on every run. Never hand-edited. Carries sourceIdentifier, fullyQualifiedName and harvestedOn instead of curated ownership: attribution is INFERRED through the Data Element it is mapped to, not asserted on the node." .
|
||||
pr:CuratedObject a owl:Class ;
|
||||
rdfs:label "Curated Object (deprecated)" ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:DefinedObject ;
|
||||
rdfs:comment "v1.4 term. Renamed because 'curated' is governance jargon; 'defined' says the same thing to a business reader. No instance ever named this class directly." .
|
||||
|
||||
pr:OwnershipLayerObject a owl:Class ; rdfs:subClassOf pr:CuratedObject ;
|
||||
pr:CapturedObject a owl:Class ; rdfs:subClassOf pr:MetaModelObject ;
|
||||
rdfs:label "Captured Object" ;
|
||||
pr:hasShortLabel "Captured" ;
|
||||
pr:authoringMode "HARVESTED" ;
|
||||
rdfs:comment "Read from a running system and rebuilt on every run. Never hand-edited. Carries sourceIdentifier, fullyQualifiedName and harvestedOn instead of declared ownership: attribution is INFERRED through the Data Element it is mapped to, never asserted on the node." .
|
||||
|
||||
pr:ObservedObject a owl:Class ;
|
||||
rdfs:label "Observed Object (deprecated)" ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:CapturedObject ;
|
||||
rdfs:comment "v1.4 term. Renamed because 'observed' is passive and technical; 'captured' says where it came from. No instance ever named this class directly." .
|
||||
|
||||
pr:OwnershipLayerObject a owl:Class ; rdfs:subClassOf pr:DefinedObject ;
|
||||
rdfs:label "Ownership & Categorization Layer Object" .
|
||||
pr:BusinessLayerObject a owl:Class ; rdfs:subClassOf pr:CuratedObject ;
|
||||
pr:BusinessLayerObject a owl:Class ; rdfs:subClassOf pr:DefinedObject ;
|
||||
rdfs:label "Business Layer Object" .
|
||||
pr:LogicalLayerObject a owl:Class ; rdfs:subClassOf pr:CuratedObject ;
|
||||
pr:LogicalLayerObject a owl:Class ; rdfs:subClassOf pr:DefinedObject ;
|
||||
rdfs:label "Logical Layer Object" ;
|
||||
rdfs:comment "How the data is structured." .
|
||||
pr:DeliveryLayerObject a owl:Class ; rdfs:subClassOf pr:CuratedObject ;
|
||||
pr:DeliveryLayerObject a owl:Class ; rdfs:subClassOf pr:DefinedObject ;
|
||||
rdfs:label "Delivery Layer Object" ;
|
||||
rdfs:comment "What we promise, to whom, until when. A different question from how the data is structured, hence a layer of its own: version, owner, changelog, support channel, consumers to warn." .
|
||||
pr:PhysicalLayerObject a owl:Class ; rdfs:subClassOf pr:ObservedObject ;
|
||||
rdfs:label "Physical Layer Object" .
|
||||
pr:ConsumptionLayerObject a owl:Class ; rdfs:subClassOf pr:ObservedObject ;
|
||||
pr:PhysicalLayerObject a owl:Class ; rdfs:subClassOf pr:MetaModelObject ;
|
||||
rdfs:label "Physical Layer Object" ;
|
||||
rdfs:comment """The one layer whose members do NOT share a provenance, which is why this class -- unlike the other five layer roots -- says nothing about it.
|
||||
|
||||
A System is DEFINED: somebody decides that MDM Product is a system worth tracking, and names it. Nobody harvests the list of systems that matter. Everything beneath a system is CAPTURED: databases, schemas, data structures, fields, keys and transformations are read from what is running.
|
||||
|
||||
Until v1.4 this class was itself declared a kind of Captured Object, which made every physical class captured by construction and put the five seeded Systems in breach of the harvest rules. The two axes are meant to be orthogonal; that shortcut collapsed them.""" .
|
||||
pr:ConsumptionLayerObject a owl:Class ; rdfs:subClassOf pr:CapturedObject ;
|
||||
rdfs:label "Consumption Layer Object" ;
|
||||
rdfs:comment "The BI estate. Separate from Physical because BI assets have their own lifecycle and their own owner: a dashboard belongs to its author, not to the Data Domain that owns the underlying data." .
|
||||
rdfs:comment "The BI estate. Separate from Physical because BI assets have their own lifecycle and their own owner: a dashboard belongs to its author, not to the Data Domain that owns the underlying data." ;
|
||||
pr:hasShortLabel "Consumption" .
|
||||
|
||||
|
||||
#################################################################
|
||||
# LAYER 1 - OWNERSHIP & CATEGORIZATION (curated)
|
||||
# LAYER 1 - OWNERSHIP & CATEGORIZATION (defined)
|
||||
#################################################################
|
||||
|
||||
pr:DataDomain a owl:Class ; rdfs:subClassOf pr:OwnershipLayerObject ;
|
||||
rdfs:label "Data Domain" .
|
||||
rdfs:label "Data Domain" ;
|
||||
pr:hasShortLabel "Domain" .
|
||||
|
||||
pr:SubDomain a owl:Class ; rdfs:subClassOf pr:OwnershipLayerObject ;
|
||||
rdfs:label "Sub-Domain" .
|
||||
rdfs:label "Sub-Domain" ;
|
||||
pr:hasShortLabel "Sub-domain" .
|
||||
|
||||
pr:BusinessObject a owl:Class ; rdfs:subClassOf pr:OwnershipLayerObject ;
|
||||
rdfs:label "Business Object" ;
|
||||
rdfs:comment "The single anchor of accountability, which is why it stays in the Ownership layer: it is the one object where a steward is declared, and Data Objects and Data Elements inherit from it. It carries NO business definition of its own -- its meaning comes from its aboutConcept. What it does carry is a perimeter: the subject it is about, and the notions needed to read it." .
|
||||
rdfs:comment "The single anchor of accountability, which is why it stays in the Ownership layer: it is the one object where a steward is declared, and Data Objects and Data Elements inherit from it. It carries NO business definition of its own -- its meaning comes from its aboutConcept. What it does carry is a perimeter: the subject it is about, and the notions needed to read it." ;
|
||||
pr:hasShortLabel "Business object" .
|
||||
|
||||
|
||||
#################################################################
|
||||
# LAYER 2 - BUSINESS (curated)
|
||||
# LAYER 2 - BUSINESS (defined)
|
||||
#################################################################
|
||||
|
||||
pr:BusinessConcept a owl:Class ; rdfs:subClassOf pr:BusinessLayerObject ;
|
||||
rdfs:label "Business Concept" ;
|
||||
rdfs:comment "A shared business notion WITHOUT a formula. The presence of a formula is the sole discriminator against Metric (rule BR-003)." .
|
||||
rdfs:comment "A shared business notion WITHOUT a formula. The presence of a formula is the sole discriminator against Metric (rule BR-003)." ;
|
||||
pr:hasShortLabel "Business concept" .
|
||||
|
||||
pr:Metric a owl:Class ; rdfs:subClassOf pr:BusinessLayerObject ;
|
||||
rdfs:label "Metric" ;
|
||||
rdfs:comment "A quantifiable measurement WITH a formula, a unit and a grain. Under BR-013 a Metric carries the harmonised CALCULATION RULE; variants that differ only by analysis context are Data Elements linked back via computedBy." .
|
||||
rdfs:comment "A quantifiable measurement WITH a formula, a unit and a grain. Under BR-013 a Metric carries the harmonised CALCULATION RULE; variants that differ only by analysis context are Data Elements linked back via computedBy." ;
|
||||
pr:hasShortLabel "Metric" .
|
||||
|
||||
pr:KPI a owl:Class ; rdfs:subClassOf pr:Metric ;
|
||||
rdfs:label "Key Performance Indicator" ;
|
||||
rdfs:comment "An elevated Metric. Use this class rather than the deprecated isKPI flag." .
|
||||
rdfs:comment "An elevated Metric. Use this class rather than the deprecated isKPI flag." ;
|
||||
pr:hasShortLabel "KPI" .
|
||||
|
||||
|
||||
#################################################################
|
||||
# LAYER 3 - LOGICAL (curated)
|
||||
# LAYER 3 - LOGICAL (defined)
|
||||
#################################################################
|
||||
|
||||
pr:DataObject a owl:Class ; rdfs:subClassOf pr:LogicalLayerObject ;
|
||||
rdfs:label "Data Object" ;
|
||||
rdfs:comment "The pivot: represents exactly one Business Object, is composed of Data Elements, and is materialized as one or more Physical Relations. The single junction between governance and technology." .
|
||||
rdfs:comment "The pivot: represents exactly one Business Object, is composed of Data Elements, and is materialized as one or more Physical Relations. The single junction between governance and technology." ;
|
||||
pr:hasShortLabel "Data object" .
|
||||
|
||||
pr:DataElement a owl:Class ; rdfs:subClassOf pr:LogicalLayerObject ;
|
||||
rdfs:label "Data Element" ;
|
||||
pr:curationMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment "The finest curated unit. Its mapping to a physical Field is the ONLY place where the curated graph and the observed graph meet: proposed automatically by name and type matching, confirmed by a Data Steward." .
|
||||
pr:authoringMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment "The finest defined unit. Its mapping to a physical Field is the ONLY place where the defined graph and the captured graph meet: proposed automatically by name and type matching, confirmed by a Data Steward." ;
|
||||
pr:hasShortLabel "Data element" .
|
||||
|
||||
pr:DataAsset a owl:Class ; rdfs:subClassOf pr:LogicalLayerObject ;
|
||||
rdfs:label "Data Asset (deprecated)" ;
|
||||
@@ -248,70 +377,94 @@ pr:DataAsset a owl:Class ; rdfs:subClassOf pr:LogicalLayerObject ;
|
||||
|
||||
|
||||
#################################################################
|
||||
# LAYER 4 - DELIVERY (curated)
|
||||
# LAYER 4 - DELIVERY (defined)
|
||||
#################################################################
|
||||
|
||||
pr:DataProduct a owl:Class ; rdfs:subClassOf pr:DeliveryLayerObject ;
|
||||
rdfs:label "Data Product" ;
|
||||
rdfs:comment "The unit of delivery: what carries a version number, an owner, a changelog, a support channel and a list of consumers to warn. It has no single technical counterpart, and should not: physically it often lands on a Snowflake schema or a dbt project, but that is not what defines it. Operated by exactly one Sub-Domain -- it is a consumable, and there must be no ambiguity about who runs it. Candidate alignment: dcat:Dataset / DPROD." .
|
||||
rdfs:comment "The unit of delivery: what carries a version number, an owner, a changelog, a support channel and a list of consumers to warn. It has no single technical counterpart, and should not: physically it often lands on a Snowflake schema or a dbt project, but that is not what defines it. Operated by exactly one Sub-Domain -- it is a consumable, and there must be no ambiguity about who runs it. Candidate alignment: dcat:Dataset / DPROD." ;
|
||||
pr:hasShortLabel "Data product" .
|
||||
|
||||
pr:DataInterface a owl:Class ; rdfs:subClassOf pr:DeliveryLayerObject ;
|
||||
rdfs:label "Data Interface" ;
|
||||
rdfs:comment "The channel through which a consumer actually gets the data: a Snowflake secure share or listing, a consumption schema with its grants, a file extract to a panel partner, an API or reverse-ETL feed. Not a Data Object (that is structure) and not a BI Data Source (that is one consumer among others). Verifiable: a grant, a share or an endpoint either exists or it does not. The output port in data-mesh terms." .
|
||||
rdfs:comment "The channel through which a consumer actually gets the data: a Snowflake secure share or listing, a consumption schema with its grants, a file extract to a panel partner, an API or reverse-ETL feed. Not a Data Object (that is structure) and not a BI Data Source (that is one consumer among others). Verifiable: a grant, a share or an endpoint either exists or it does not. The output port in data-mesh terms." ;
|
||||
pr:hasShortLabel "Data interface" .
|
||||
|
||||
pr:DataContract a owl:Class ; rdfs:subClassOf pr:DeliveryLayerObject ;
|
||||
rdfs:label "Data Contract" ;
|
||||
rdfs:comment "The service commitment attached to a Data Product: schema, freshness, quality thresholds, support, breaking-change notice period. Candidate alignment: ODCS (Bitol)." .
|
||||
rdfs:comment "The service commitment attached to a Data Product: schema, freshness, quality thresholds, support, breaking-change notice period. Candidate alignment: ODCS (Bitol)." ;
|
||||
pr:hasShortLabel "Data contract" .
|
||||
|
||||
|
||||
#################################################################
|
||||
# LAYER 5 - PHYSICAL (observed)
|
||||
# LAYER 5 - PHYSICAL (captured)
|
||||
#################################################################
|
||||
|
||||
pr:System a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject ;
|
||||
pr:System a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:DefinedObject ;
|
||||
rdfs:label "System" ;
|
||||
pr:harvestSource "Manually seeded once, then referenced. Replaces the free-text hasSourceSystem." ;
|
||||
rdfs:comment "A real system: Snowflake, MDM Product, MDM Customer, a panel provider feed, Tableau Server, Looker. Making this a node rather than a string is what makes 'what depends on MDM Product?' answerable." .
|
||||
pr:authoringMode "ASSERTED" ;
|
||||
rdfs:comment "A real system: Snowflake, MDM Product, MDM Customer, a panel provider feed, Tableau Server, Looker. Making this a node rather than a string is what makes 'what depends on MDM Product?' answerable." ;
|
||||
pr:hasShortLabel "System" .
|
||||
|
||||
pr:Database a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject ;
|
||||
pr:Database a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:CapturedObject ;
|
||||
rdfs:label "Database" ;
|
||||
pr:harvestSource "SNOWFLAKE.INFORMATION_SCHEMA.DATABASES" .
|
||||
pr:harvestSource "SNOWFLAKE.INFORMATION_SCHEMA.DATABASES" ;
|
||||
pr:hasShortLabel "Database" .
|
||||
|
||||
pr:Schema a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject ;
|
||||
pr:Schema a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:CapturedObject ;
|
||||
rdfs:label "Schema" ;
|
||||
pr:harvestSource "SNOWFLAKE.INFORMATION_SCHEMA.SCHEMATA" .
|
||||
pr:harvestSource "SNOWFLAKE.INFORMATION_SCHEMA.SCHEMATA" ;
|
||||
pr:hasShortLabel "Schema" .
|
||||
|
||||
pr:PhysicalRelation a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject ;
|
||||
rdfs:label "Physical Relation" ;
|
||||
pr:DataStructure a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:CapturedObject ;
|
||||
rdfs:label "Data Structure" ;
|
||||
pr:hasShortLabel "Table or view" ;
|
||||
pr:harvestSource "SNOWFLAKE.INFORMATION_SCHEMA.TABLES" ;
|
||||
rdfs:comment "Abstract parent of everything with columns. Specialised because impact traversal differs by kind: a View propagates impact to whatever it reads." .
|
||||
rdfs:comment """Anything that carries Fields and reads as a set of rows. Never instantiated directly: a harvest types the concrete kind, and a viewer shows that kind rather than this parent.
|
||||
|
||||
pr:BaseTable a owl:Class ; rdfs:subClassOf pr:PhysicalRelation ;
|
||||
rdfs:label "Base Table" .
|
||||
WHY THE PARENT EXISTS. Three properties need exactly this set as their scope: storedIn from a Data Object, hasField and its inverse livesIn, and dependsOn. Without it each would have to be tripled, once per concrete kind, and the checks would go with them.
|
||||
|
||||
pr:View a owl:Class ; rdfs:subClassOf pr:PhysicalRelation ;
|
||||
WHY THE NAME CHANGED. It was PhysicalRelation, from Codd, where a relation IS a table. In an ontology "relation" reads as a property, and the word locks the class into the tabular world. A Neo4j node label, a Mongo collection and a Kafka topic all carry fields; none is a relation.
|
||||
|
||||
EXTENSION POINT for non-tabular storage. Nothing at Pernod Ricard is non-tabular today, so no such class is declared -- four terms were deprecated in v1.2 precisely because nobody instantiated them. The day a graph enters scope, the insertion is additive and touches no instance, because subClassOf is transitive:
|
||||
|
||||
pr:Dataset rdfs:subClassOf pr:DataStructure .
|
||||
pr:Graph rdfs:subClassOf pr:DataStructure .
|
||||
pr:BaseTable rdfs:subClassOf pr:Dataset . # instead of DataStructure
|
||||
pr:inSchema rdfs:domain pr:Dataset . # instead of nothing
|
||||
|
||||
Existing BaseTable assertions stay DataStructure by entailment, every shape targeting DataStructure keeps working, and storedIn does not move. The extension point is paid once; the extension is paid when it arrives.""" .
|
||||
|
||||
pr:PhysicalRelation a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:CapturedObject ;
|
||||
rdfs:label "Physical Relation (deprecated)" ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:DataStructure .
|
||||
|
||||
pr:BaseTable a owl:Class ; rdfs:subClassOf pr:DataStructure ;
|
||||
rdfs:label "Base Table" ;
|
||||
pr:hasShortLabel "Base table" .
|
||||
|
||||
pr:View a owl:Class ; rdfs:subClassOf pr:DataStructure ;
|
||||
rdfs:label "View" ;
|
||||
rdfs:comment "Depends on other relations through dependsOn, so impact is transitive." .
|
||||
rdfs:comment "Depends on other relations through dependsOn, so impact is transitive." ;
|
||||
pr:hasShortLabel "View" .
|
||||
|
||||
pr:MaterializedView a owl:Class ; rdfs:subClassOf pr:PhysicalRelation ;
|
||||
rdfs:label "Materialized View" .
|
||||
pr:MaterializedView a owl:Class ; rdfs:subClassOf pr:DataStructure ;
|
||||
rdfs:label "Materialized View (deprecated)" ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:View ;
|
||||
rdfs:comment "A class standing in for an attribute: what distinguishes it is being derived, which dependsOn already states." .
|
||||
|
||||
pr:ExternalTable a owl:Class ; rdfs:subClassOf pr:PhysicalRelation ;
|
||||
pr:ExternalTable a owl:Class ; rdfs:subClassOf pr:DataStructure ;
|
||||
rdfs:label "External Table" ;
|
||||
rdfs:comment "Backed by files outside the warehouse. Marks the boundary where lineage leaves Snowflake." .
|
||||
rdfs:comment "Backed by files outside the warehouse. Marks the boundary where lineage leaves Snowflake." ;
|
||||
pr:hasShortLabel "External table" .
|
||||
|
||||
pr:Table a owl:Class ; rdfs:subClassOf pr:PhysicalRelation ;
|
||||
rdfs:label "Table (deprecated)" ;
|
||||
owl:deprecated true ;
|
||||
dcterms:isReplacedBy pr:BaseTable ;
|
||||
rdfs:comment "v0.9 term. Kept so that existing assertions still classify. Use BaseTable." .
|
||||
|
||||
pr:Field a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject ;
|
||||
pr:Field a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:CapturedObject ;
|
||||
rdfs:label "Field" ;
|
||||
pr:harvestSource "SNOWFLAKE.INFORMATION_SCHEMA.COLUMNS" ;
|
||||
rdfs:comment "A physical column. The anchor of impact analysis: everything upstream reaches a Field, everything downstream starts from one." .
|
||||
rdfs:comment "A physical column. The anchor of impact analysis: everything upstream reaches a Field, everything downstream starts from one." ;
|
||||
pr:hasShortLabel "Field" .
|
||||
|
||||
pr:KeyConstraint a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject ;
|
||||
pr:KeyConstraint a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:CapturedObject ;
|
||||
rdfs:label "Key Constraint" ;
|
||||
pr:harvestSource "SNOWFLAKE.INFORMATION_SCHEMA.TABLE_CONSTRAINTS + KEY_COLUMN_USAGE" ;
|
||||
rdfs:comment "Gives foreign keys a home. Rule OW-006 says an FK is not a Data Element - true, but it still needs somewhere to live, and it lets the asserted DataObject-references-DataObject edge be checked against reality." .
|
||||
@@ -322,34 +475,39 @@ pr:PrimaryKey a owl:Class ; rdfs:subClassOf pr:KeyConstraint ;
|
||||
pr:ForeignKeyConstraint a owl:Class ; rdfs:subClassOf pr:KeyConstraint ;
|
||||
rdfs:label "Foreign Key Constraint" .
|
||||
|
||||
pr:Transformation a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , prov:Activity ;
|
||||
pr:Transformation a owl:Class ; rdfs:subClassOf pr:PhysicalLayerObject , pr:CapturedObject , prov:Activity ;
|
||||
rdfs:label "Transformation" ;
|
||||
pr:harvestSource "dbt manifest.json, Snowflake TASKS, Azure Data Factory pipelines" ;
|
||||
rdfs:comment "The code that turns inputs into outputs: a dbt model, a Snowflake task, an ADF pipeline. Subclass of prov:Activity so that lineage is expressed in a standard vocabulary rather than a private one." .
|
||||
rdfs:comment "The code that turns inputs into outputs: a dbt model, a Snowflake task, an ADF pipeline. Subclass of prov:Activity so that lineage is expressed in a standard vocabulary rather than a private one." ;
|
||||
pr:hasShortLabel "Transformation" .
|
||||
|
||||
|
||||
#################################################################
|
||||
# LAYER 6 - CONSUMPTION (observed)
|
||||
# LAYER 6 - CONSUMPTION (captured)
|
||||
#################################################################
|
||||
|
||||
pr:BIWorkspace a owl:Class ; rdfs:subClassOf pr:ConsumptionLayerObject ;
|
||||
rdfs:label "BI Workspace" ;
|
||||
pr:harvestSource "Tableau Metadata API (Project/Site) ; Looker API (Model)" .
|
||||
pr:harvestSource "Tableau Metadata API (Project/Site) ; Looker API (Model)" ;
|
||||
pr:hasShortLabel "BI workspace" .
|
||||
|
||||
pr:BIDataSource a owl:Class ; rdfs:subClassOf pr:ConsumptionLayerObject ;
|
||||
rdfs:label "BI Data Source" ;
|
||||
pr:harvestSource "Tableau Published Datasource ; Looker Explore" ;
|
||||
rdfs:comment "The semantic surface a report is built on. This is where BI meets the warehouse." .
|
||||
rdfs:comment "The semantic surface a report is built on. This is where BI meets the warehouse." ;
|
||||
pr:hasShortLabel "BI data source" .
|
||||
|
||||
pr:BIField a owl:Class ; rdfs:subClassOf pr:ConsumptionLayerObject ;
|
||||
rdfs:label "BI Field" ;
|
||||
pr:harvestSource "Tableau calculated fields ; LookML measures and dimensions" ;
|
||||
rdfs:comment "A field as a business user sees it. realizesMetric is what turns a certified Metric from a definition on paper into something measurable against the real BI estate." .
|
||||
rdfs:comment "A field as a business user sees it. exposesMetric is what turns a certified Metric from a definition on paper into something measurable against the real BI estate." ;
|
||||
pr:hasShortLabel "BI field" .
|
||||
|
||||
pr:BIReport a owl:Class ; rdfs:subClassOf pr:ConsumptionLayerObject ;
|
||||
rdfs:label "BI Report" ;
|
||||
pr:harvestSource "Tableau Workbook/Sheet ; Looker Look/Dashboard" ;
|
||||
rdfs:comment "What a Data Governance Lead actually cares about in an impact analysis: not that a column changed, but which reports break and who to warn." .
|
||||
rdfs:comment "What a Data Governance Lead actually cares about in an impact analysis: not that a column changed, but which reports break and who to warn." ;
|
||||
pr:hasShortLabel "BI report" .
|
||||
|
||||
|
||||
#################################################################
|
||||
@@ -357,28 +515,34 @@ pr:BIReport a owl:Class ; rdfs:subClassOf pr:ConsumptionLayerObject ;
|
||||
#################################################################
|
||||
|
||||
pr:Actor a owl:Class ; rdfs:label "Actor" ;
|
||||
rdfs:comment "A person or a team. Deliberately NOT a MetaModelObject: people are not subject to ownership and lifecycle rules." .
|
||||
rdfs:comment "A person or a team. Deliberately NOT a MetaModelObject: people are not subject to ownership and lifecycle rules." ;
|
||||
pr:hasShortLabel "Actor" .
|
||||
|
||||
pr:DataDomainOwner a owl:Class ; rdfs:subClassOf pr:Actor ;
|
||||
rdfs:label "Data Domain Owner" ;
|
||||
rdfs:comment "Accountable for a Data Domain. Exactly one per domain." .
|
||||
rdfs:comment "Accountable for a Data Domain. Exactly one per domain." ;
|
||||
pr:hasShortLabel "Domain owner" .
|
||||
|
||||
pr:SubDomainOwner a owl:Class ; rdfs:subClassOf pr:Actor ;
|
||||
rdfs:label "Sub-Domain Owner" ;
|
||||
rdfs:comment "Accountable for a Sub-Domain. Exactly one per sub-domain." .
|
||||
rdfs:comment "Accountable for a Sub-Domain. Exactly one per sub-domain." ;
|
||||
pr:hasShortLabel "Sub-domain owner" .
|
||||
|
||||
pr:DataGovernanceLead a owl:Class ; rdfs:subClassOf pr:Actor ;
|
||||
rdfs:label "Data Governance Lead" ;
|
||||
pr:hasAcronym "DGL" ;
|
||||
rdfs:comment "Runs governance for a Data Domain. The acronym belongs in hasAcronym, not in the label (rule NR-005)." .
|
||||
rdfs:comment "Runs governance for a Data Domain. The acronym belongs in hasAcronym, not in the label (rule NR-005)." ;
|
||||
pr:hasShortLabel "Data governance lead" .
|
||||
|
||||
pr:DataProductOwner a owl:Class ; rdfs:subClassOf pr:Actor ;
|
||||
rdfs:label "Data Product Owner" ;
|
||||
rdfs:comment "Runs a Data Product day to day: releases, changelog, support, consumer communication. Belongs to the Sub-Domain that operates the product." .
|
||||
rdfs:comment "Runs a Data Product day to day: releases, changelog, support, consumer communication. Belongs to the Sub-Domain that operates the product." ;
|
||||
pr:hasShortLabel "Product owner" .
|
||||
|
||||
pr:DataSteward a owl:Class ; rdfs:subClassOf pr:Actor ;
|
||||
rdfs:label "Data Steward" ;
|
||||
rdfs:comment "Monitors a Business Object. Declared there and nowhere else: Data Objects and Data Elements inherit their steward, so that no column can ever have two answers to 'who watches this'." .
|
||||
rdfs:comment "Monitors a Business Object. Declared there and nowhere else: Data Objects and Data Elements inherit their steward, so that no column can ever have two answers to 'who watches this'." ;
|
||||
pr:hasShortLabel "Steward" .
|
||||
|
||||
|
||||
#################################################################
|
||||
@@ -495,10 +659,14 @@ pr:hasElement a owl:ObjectProperty ;
|
||||
rdfs:label "has element" ;
|
||||
rdfs:domain pr:DataObject ; rdfs:range pr:DataElement .
|
||||
|
||||
pr:references a owl:ObjectProperty ;
|
||||
rdfs:label "references" ;
|
||||
pr:qualifiedBy a owl:ObjectProperty ;
|
||||
rdfs:label "qualified by" ;
|
||||
rdfs:domain pr:DataObject ; rdfs:range pr:DataObject ;
|
||||
rdfs:comment "Foreign-key reference between Data Objects. NOT ownership. Now checkable against the harvested ForeignKeyConstraint objects." .
|
||||
rdfs:comment "The Data Objects that give this one its analysis context: a fact dataset is qualified by Product, Customer, Currency and Date. Physically a foreign key, which is why it is checkable against the harvested ForeignKeyConstraint objects -- but the name says the reason rather than the mechanism. NOT ownership. It is also what carries the grain of a fact object, whose own elements are measures and whose keys are not Data Elements (OW-006)." .
|
||||
|
||||
pr:references a owl:ObjectProperty ;
|
||||
rdfs:label "references (deprecated)" ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:qualifiedBy .
|
||||
|
||||
#################################################################
|
||||
# OBJECT PROPERTIES - Delivery
|
||||
@@ -516,7 +684,7 @@ pr:exposes a owl:ObjectProperty ;
|
||||
|
||||
pr:servedBy a owl:ObjectProperty ;
|
||||
rdfs:label "served by" ;
|
||||
rdfs:domain pr:DataInterface ; rdfs:range pr:PhysicalRelation ;
|
||||
rdfs:domain pr:DataInterface ; rdfs:range pr:DataStructure ;
|
||||
rdfs:comment "What physically backs the interface: the shared relations, the extract source." .
|
||||
|
||||
pr:governedBy a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
@@ -539,22 +707,43 @@ pr:usesDataObject a owl:ObjectProperty ;
|
||||
|
||||
|
||||
#################################################################
|
||||
# OBJECT PROPERTIES - the curated / observed seam
|
||||
# OBJECT PROPERTIES - the defined / captured seam
|
||||
# These two are the ONLY edges crossing from asserted to harvested.
|
||||
# Everything else is either pure governance or pure machine.
|
||||
#################################################################
|
||||
|
||||
pr:materializedAs a owl:ObjectProperty ;
|
||||
rdfs:label "materialized as" ;
|
||||
rdfs:domain pr:DataObject ; rdfs:range pr:PhysicalRelation ;
|
||||
pr:curationMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment "Data Object to physical relation. Not functional: the same Data Object exists in DEV, UAT and PROD, and sometimes across several tables." .
|
||||
rdfs:label "materialized as (deprecated)" ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:storedIn ;
|
||||
rdfs:comment "Redundant once storedIn serves two granularities. One verb fewer, and the seam counts one relation instead of two." .
|
||||
|
||||
pr:storedIn a owl:ObjectProperty ;
|
||||
rdfs:label "stored in" ;
|
||||
pr:authoringMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment """Where a logical artefact actually sits. One relation at two granularities, like represents:
|
||||
DataObject storedIn DataStructure (a table, a view, later a node label)
|
||||
DataElement storedIn Field (a column, later a node property)
|
||||
|
||||
Range left open and scoped by SHACL per class, because the two uses have different targets.
|
||||
|
||||
THE SEAM. This is the one relation crossing from what governance defines to what a harvester captures, and the one thing a steward confirms: the reconciliation job proposes the mapping on fully qualified name and type, a person accepts it. It is also what makes end-to-end impact analysis possible.
|
||||
|
||||
Not functional: the same object exists in DEV, UAT and PROD, and a Data Element may sit in several Fields -- see primaryLocation for the authoritative one. Renamed from physicalizedIn, which was jargon.""" .
|
||||
|
||||
pr:primaryLocation a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:subPropertyOf pr:storedIn ;
|
||||
rdfs:label "primary location" ;
|
||||
rdfs:domain pr:DataElement ; rdfs:range pr:Field ;
|
||||
pr:authoringMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment """The authoritative Field among the several a Data Element may sit in -- the others being copies, replicas or downstream materialisations.
|
||||
|
||||
A SUB-PROPERTY of storedIn on purpose, not a parallel relation. Entailment then guarantees the primary location is always among the locations, so the two can never disagree; two independent properties would allow a Field marked primary here and absent from storedIn there.
|
||||
|
||||
Primary and replica rather than master and slave: the industry has moved on, and it reads better to the business.""" .
|
||||
|
||||
pr:physicalizedIn a owl:ObjectProperty ;
|
||||
rdfs:label "physicalized in" ;
|
||||
rdfs:domain pr:DataElement ; rdfs:range pr:Field ;
|
||||
pr:curationMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment "Data Element to physical column, 1..n. Proposed by the reconciliation job on fullyQualifiedName and type, confirmed by a Data Steward. This single edge is what makes end-to-end impact analysis possible." .
|
||||
rdfs:label "physicalized in (deprecated)" ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:storedIn .
|
||||
|
||||
|
||||
#################################################################
|
||||
@@ -564,7 +753,11 @@ pr:physicalizedIn a owl:ObjectProperty ;
|
||||
pr:sourcedFrom a owl:ObjectProperty ;
|
||||
rdfs:label "sourced from" ;
|
||||
rdfs:range pr:System ;
|
||||
rdfs:comment "Replaces the free-text hasSourceSystem. Domain deliberately omitted: applies to Data Elements, Physical Relations and BI Data Sources alike." .
|
||||
rdfs:comment """The System holding the authoritative data for this object. Replaces the free-text hasSource, and answers a question that text could not: which objects depend on MDM Product.
|
||||
|
||||
Domain deliberately omitted -- it applies to Data Elements, Data Structures, Metrics and BI Data Sources alike, and the scope lives in the shapes.
|
||||
|
||||
It also settles a naming collision. As a string, "source" meant a system here and a BI surface in BIDataSource, two readings of one word. As a relation towards System, the two are different kinds of thing and the ambiguity disappears.""" .
|
||||
|
||||
pr:hasSystemType a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "has system type" ;
|
||||
@@ -580,25 +773,27 @@ pr:inDatabase a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
|
||||
pr:inSchema a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "in schema" ;
|
||||
rdfs:domain pr:PhysicalRelation ; rdfs:range pr:Schema .
|
||||
rdfs:range pr:Schema ;
|
||||
rdfs:comment "Domain deliberately not declared, and the shapes must keep this OPTIONAL: Neo4j has no schema and BigQuery calls the level a dataset. A minCount 1 would break on the first harvest outside Snowflake. It is also the only property that would distinguish a tabular Dataset from a Graph, which is why that intermediate level is not declared yet -- one client does not pay for a level of hierarchy." .
|
||||
|
||||
pr:hasField a owl:ObjectProperty ;
|
||||
rdfs:label "has field" ;
|
||||
rdfs:domain pr:PhysicalRelation ; rdfs:range pr:Field ;
|
||||
rdfs:domain pr:DataStructure ; rdfs:range pr:Field ;
|
||||
owl:inverseOf pr:livesIn ;
|
||||
rdfs:comment "Domain widened from Table to PhysicalRelation so that views and external tables carry columns too. Inverse now declared - in v0.9 hasField and livesIn were inverses in fact but not in the model, so they were free to diverge." .
|
||||
|
||||
pr:livesIn a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "lives in" ;
|
||||
rdfs:domain pr:Field ; rdfs:range pr:PhysicalRelation .
|
||||
rdfs:domain pr:Field ; rdfs:range pr:DataStructure .
|
||||
|
||||
pr:deployedIn a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "deployed in" ;
|
||||
rdfs:domain pr:ObservedObject ; rdfs:range pr:Environment .
|
||||
rdfs:domain pr:CapturedObject ; rdfs:range pr:Environment .
|
||||
|
||||
pr:constrainsRelation a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "constrains relation" ;
|
||||
rdfs:domain pr:KeyConstraint ; rdfs:range pr:PhysicalRelation .
|
||||
rdfs:label "constrains relation (deprecated)" ;
|
||||
owl:deprecated true ;
|
||||
rdfs:comment "Derivable: constrainsField then livesIn gives the relation. An asserted edge redundant with an existing path is a divergence waiting to happen." .
|
||||
|
||||
pr:constrainsField a owl:ObjectProperty ;
|
||||
rdfs:label "constrains field" ;
|
||||
@@ -616,15 +811,15 @@ pr:toField a owl:ObjectProperty ;
|
||||
pr:consumes a owl:ObjectProperty ;
|
||||
rdfs:subPropertyOf prov:used ;
|
||||
rdfs:label "consumes" ;
|
||||
rdfs:domain pr:Transformation ; rdfs:range pr:PhysicalRelation .
|
||||
rdfs:domain pr:Transformation ; rdfs:range pr:DataStructure .
|
||||
|
||||
pr:produces a owl:ObjectProperty ;
|
||||
rdfs:label "produces" ;
|
||||
rdfs:domain pr:Transformation ; rdfs:range pr:PhysicalRelation .
|
||||
rdfs:domain pr:Transformation ; rdfs:range pr:DataStructure .
|
||||
|
||||
pr:dependsOn a owl:ObjectProperty , owl:TransitiveProperty ;
|
||||
rdfs:label "depends on" ;
|
||||
rdfs:domain pr:PhysicalRelation ; rdfs:range pr:PhysicalRelation ;
|
||||
rdfs:domain pr:DataStructure ; rdfs:range pr:DataStructure ;
|
||||
pr:harvestSource "SNOWFLAKE.ACCOUNT_USAGE.OBJECT_DEPENDENCIES" ;
|
||||
rdfs:comment "Relation-level dependency, view to table. Transitive by nature; in practice compute the closure at query time in Snowflake rather than materialising it with a reasoner." .
|
||||
|
||||
@@ -646,7 +841,7 @@ pr:inWorkspace a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
|
||||
pr:biConsumes a owl:ObjectProperty ;
|
||||
rdfs:label "BI consumes" ;
|
||||
rdfs:domain pr:BIDataSource ; rdfs:range pr:PhysicalRelation ;
|
||||
rdfs:domain pr:BIDataSource ; rdfs:range pr:DataStructure ;
|
||||
pr:harvestSource "Tableau Metadata API (GraphQL) ; Looker Explore SQL" .
|
||||
|
||||
pr:hasBIField a owl:ObjectProperty ;
|
||||
@@ -664,11 +859,11 @@ pr:biDerivedFrom a owl:ObjectProperty ;
|
||||
rdfs:domain pr:BIField ; rdfs:range pr:Field ;
|
||||
rdfs:comment "Closes the last gap in the impact chain: from a dashboard field back to the warehouse column." .
|
||||
|
||||
pr:realizesMetric a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "realizes metric" ;
|
||||
pr:exposesMetric a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "exposes metric" ;
|
||||
rdfs:domain pr:BIField ; rdfs:range pr:Metric ;
|
||||
pr:curationMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment """The harmonisation measure: how many distinct BI Fields realize one certified Metric, and do their expressions agree. Turns 'we harmonised the definitions' from a claim into a count over the real BI estate.
|
||||
pr:authoringMode "PROPOSED_CONFIRMED" ;
|
||||
rdfs:comment """The harmonisation measure: how many distinct BI Fields expose one certified Metric, and do their expressions agree. Turns 'we harmonised the definitions' from a claim into a count over the real BI estate.
|
||||
|
||||
In principle this is derivable from the lineage chain Metric -> DataElement -> Field -> BIField, since lineage carries semantic inheritance. In practice that chain will have holes -- four hops, one of them PROPOSED_CONFIRMED, another harvested from an API that does not resolve custom SQL, extracts or cascaded calculated fields -- and the question it answers is too important to depend on them.
|
||||
|
||||
@@ -695,7 +890,7 @@ pr:ownedBy a owl:ObjectProperty ;
|
||||
|
||||
pr:owningDomain a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "owning Data Domain" ; rdfs:range pr:DataDomain ;
|
||||
rdfs:comment """The single Data Domain with authority to define the object's rule. Absent on Observed Objects: a Snowflake column is attributed through the Data Element mapped to it, never asserted directly.
|
||||
rdfs:comment """The single Data Domain with authority to define the object's rule. Absent on Captured Objects: a Snowflake column is attributed through the Data Element mapped to it, never asserted directly.
|
||||
|
||||
Unlike the steward, this one is RE-DECLARABLE on a Data Element. It is inherited by default from the parent chain, but OW-002 attributes an element to the domain that defines its RULE, and a borrowed element -- Brand Code sitting in a Sell Out fact object -- has its rule elsewhere. A Data Element whose owningDomain differs from its parent's is a borrowed element: a signal to check against its represents, not an anomaly to fix.""" .
|
||||
|
||||
@@ -734,11 +929,25 @@ pr:hasActivationStatus a owl:ObjectProperty , owl:FunctionalProperty ;
|
||||
|
||||
pr:hasIdentifier a owl:DatatypeProperty , owl:FunctionalProperty ; rdfs:label "identifier" ; rdfs:range xsd:string .
|
||||
pr:hasName a owl:DatatypeProperty , owl:FunctionalProperty ; rdfs:label "canonical name" ; rdfs:range xsd:string .
|
||||
|
||||
pr:hasShortLabel a owl:DatatypeProperty , owl:FunctionalProperty ;
|
||||
rdfs:label "short label" ; rdfs:range xsd:string ;
|
||||
rdfs:comment """The name screens use, where the canonical name is the exhaustive one: Domain for Data Domain, SODH Gold for Sell Out Data Hub - Gold.
|
||||
|
||||
Declared rather than left to each interface. The same object was being called two different things depending on where you looked, because every viewer kept a display dictionary of its own. One name is authoritative, the other is short, and both live in the model.""" .
|
||||
pr:hasStatus a owl:DatatypeProperty ; rdfs:label "status" ; rdfs:range xsd:string .
|
||||
pr:hasVersion a owl:DatatypeProperty ; rdfs:label "version" ; rdfs:range xsd:string .
|
||||
pr:createdOn a owl:DatatypeProperty ; rdfs:label "created on" ; rdfs:range xsd:date .
|
||||
pr:lastReviewedOn a owl:DatatypeProperty ; rdfs:label "last reviewed on" ; rdfs:range xsd:date .
|
||||
pr:hasSource a owl:DatatypeProperty ; rdfs:label "back-doc source" ; rdfs:range xsd:string .
|
||||
pr:hasSource a owl:DatatypeProperty ; rdfs:label "source of truth (deprecated)" ; rdfs:range xsd:string ;
|
||||
owl:deprecated true ; dcterms:isReplacedBy pr:sourcedFrom ;
|
||||
rdfs:comment """The system holding the authoritative data for this object: SODH Gold, MDM Product, Group Finance.
|
||||
|
||||
ONE MEANING ONLY. It had drifted into naming the document a record came from ("SODH back-doc v0.7"), and into packing a system and a relation into one string ("SODH Gold / F_SELL_OUT"). The relation belongs in physicalName; the document belongs nowhere -- provenance of a record is not a property of the thing it describes.
|
||||
|
||||
MUST NOT appear on a Business Concept: a concept has no data source. Its authority is its owning domain and its definition is published in the glossary. Enforced by SHACL.
|
||||
|
||||
On a Metric it is asserted rather than derived, by exception, because "where can I get this metric" is a first-order question and the derivation chain (computedBy, then the data object holding the element) will have gaps before harvesting. A shape checks the assertion against the elements.""" .
|
||||
pr:arbitrationStatus a owl:DatatypeProperty ; rdfs:label "arbitration status" ; rdfs:range xsd:string ;
|
||||
rdfs:comment "TO_ARBITRATE blocks publication (OW-007). Use this on the object rather than tracking arbitration in a side spreadsheet." .
|
||||
|
||||
@@ -792,18 +1001,21 @@ pr:sourceIdentifier a owl:DatatypeProperty , owl:FunctionalProperty ;
|
||||
rdfs:comment "Native immutable id in the source system (Snowflake object id, Tableau LUID, Looker id). Makes reconciliation idempotent and survives renames, which names do not." .
|
||||
|
||||
pr:harvestedOn a owl:DatatypeProperty ; rdfs:label "harvested on" ; rdfs:range xsd:dateTime ;
|
||||
rdfs:comment "Staleness marker. An Observed Object not refreshed by the last run is a deletion candidate, not a fact." .
|
||||
rdfs:comment "Staleness marker. A Captured Object not refreshed by the last run is a deletion candidate, not a fact." .
|
||||
|
||||
pr:hasPhysicalDataType a owl:DatatypeProperty ; rdfs:label "physical data type" ; rdfs:range xsd:string .
|
||||
pr:isNullable a owl:DatatypeProperty ; rdfs:label "is nullable" ; rdfs:range xsd:boolean .
|
||||
pr:ordinalPosition a owl:DatatypeProperty ; rdfs:label "ordinal position" ; rdfs:range xsd:integer .
|
||||
pr:hasViewDefinition a owl:DatatypeProperty ; rdfs:label "view definition" ; rdfs:range xsd:string .
|
||||
pr:hasVendor a owl:DatatypeProperty ; rdfs:label "vendor" ; rdfs:range xsd:string .
|
||||
pr:hasVendor a owl:DatatypeProperty ; rdfs:label "vendor (deprecated)" ; rdfs:range xsd:string ;
|
||||
owl:deprecated true .
|
||||
pr:definedBy a owl:DatatypeProperty ; rdfs:label "defined by (code URI)" ; rdfs:range xsd:anyURI ;
|
||||
rdfs:comment "Git URI of the code behind a Transformation. Connects the graph to the repository." .
|
||||
|
||||
# ---- Usage evidence (the rationalisation argument)
|
||||
pr:approximateRowCount a owl:DatatypeProperty ; rdfs:label "approximate row count" ; rdfs:range xsd:integer .
|
||||
pr:approximateRowCount a owl:DatatypeProperty ; rdfs:label "approximate row count (deprecated)" ; rdfs:range xsd:integer ;
|
||||
owl:deprecated true ;
|
||||
rdfs:comment "Volumetry with no identified use. queryCount30d and lastQueriedOn carry the rationalisation argument; row count does not." .
|
||||
pr:lastQueriedOn a owl:DatatypeProperty ; rdfs:label "last queried on" ; rdfs:range xsd:dateTime ;
|
||||
pr:harvestSource "SNOWFLAKE.ACCOUNT_USAGE.ACCESS_HISTORY" ;
|
||||
rdfs:comment "Lets the model say 'documented but unused for eight months'. A rationalisation argument that costs nothing and is denominated in warehouse spend." .
|
||||
@@ -818,7 +1030,7 @@ pr:hasExpression a owl:DatatypeProperty ; rdfs:label "BI expression" ; rdfs:rang
|
||||
# DISJOINTNESS
|
||||
#################################################################
|
||||
|
||||
[] a owl:AllDisjointClasses ; owl:members ( pr:CuratedObject pr:ObservedObject ) .
|
||||
[] a owl:AllDisjointClasses ; owl:members ( pr:DefinedObject pr:CapturedObject ) .
|
||||
|
||||
[] a owl:AllDisjointClasses ; owl:members (
|
||||
pr:OwnershipLayerObject pr:BusinessLayerObject pr:LogicalLayerObject
|
||||
@@ -830,7 +1042,7 @@ pr:hasExpression a owl:DatatypeProperty ; rdfs:label "BI expression" ; rdfs:rang
|
||||
[] a owl:AllDisjointClasses ; owl:members ( pr:BusinessConcept pr:Metric ) .
|
||||
|
||||
[] a owl:AllDisjointClasses ; owl:members (
|
||||
pr:BaseTable pr:View pr:MaterializedView pr:ExternalTable ) .
|
||||
pr:BaseTable pr:View pr:ExternalTable ) .
|
||||
|
||||
[] a owl:AllDisjointClasses ; owl:members ( pr:PrimaryKey pr:ForeignKeyConstraint ) .
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SODH - data fixes v1.2
|
||||
=======================
|
||||
Four corrections found while reviewing the viewer.
|
||||
|
||||
USAGE
|
||||
python3 scripts/apply_fixes_v1_2.py # dry run
|
||||
python3 scripts/apply_fixes_v1_2.py --apply # rewrite, .bak kept
|
||||
|
||||
1. DATA DOMAIN OWNERS
|
||||
Six named owners added, plus the hasDomainOwner link. Ownership was
|
||||
readable only through the DGL until now, which conflates two roles: the
|
||||
owner is accountable for the domain, the DGL runs its governance.
|
||||
|
||||
2. hasSource CARRIED TWO MEANINGS
|
||||
On a Data Element it named the system of origin (MDM Product, Group
|
||||
Finance). On a Data Object it named the physical location (SODH Gold /
|
||||
F_SELL_OUT). Same property, two concepts -- the defect we removed from
|
||||
composedOf, still present one layer down. Split: physicalName holds the
|
||||
relation name, hasSource holds the system. This is also what makes the
|
||||
physical layer derivable: F_SELL_OUT plus 132 column names.
|
||||
|
||||
3. METRIC UNITS ARE PLURAL
|
||||
Five mother metrics compute elements in several units (9L and L, EUR and
|
||||
LC and USD). A metric states every unit its variants are expressed in; a
|
||||
Data Element states exactly one. Recomputed from the elements rather than
|
||||
asserted, so the two can never drift.
|
||||
|
||||
4. Sell Out Distribution -> Retail Distribution, matching the concept: sell
|
||||
out counts units sold, distribution measures presence in store.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
TTL = os.path.join(REPO, "instances", "sodh.ttl")
|
||||
W = 78
|
||||
|
||||
OWNERS = [
|
||||
("ex:DDO_DD_06", "Ludovic Cottier", "ex:DD_06"),
|
||||
("ex:DDO_DD_04", "David Carpio", "ex:DD_04"),
|
||||
("ex:DDO_DD_10", "Alberto Lupano", "ex:DD_10"),
|
||||
("ex:DDO_DD_05", "David Carpio", "ex:DD_05"),
|
||||
("ex:DDO_DD_16", "Julien Soisson", "ex:DD_16"),
|
||||
("ex:DDO_DD_21", "Vincent Meunier", "ex:DD_21"),
|
||||
]
|
||||
|
||||
RENAME = {"ex:BO_06_01_003": ("Sell Out Distribution", "Retail Distribution")}
|
||||
|
||||
# system of origin, once the physical location is taken out of it
|
||||
SOURCE_FIX = {
|
||||
"Snowflake (SODH Gold)": "SODH Gold",
|
||||
"SODH Gold (flag)": "SODH Gold",
|
||||
}
|
||||
|
||||
|
||||
def clauses(body):
|
||||
out, buf, i, n = [], [], 0, len(body)
|
||||
while i < n:
|
||||
c = body[i]
|
||||
if c == '"':
|
||||
j = i + 1
|
||||
while j < n and body[j] != '"':
|
||||
j += 2 if body[j] == "\\" else 1
|
||||
j = min(j + 1, n)
|
||||
buf.append(body[i:j]); i = j; continue
|
||||
if c == ";":
|
||||
out.append("".join(buf)); buf = []; i += 1; continue
|
||||
buf.append(c); i += 1
|
||||
out.append("".join(buf))
|
||||
return out
|
||||
|
||||
|
||||
def set_prop(text, subject, prop, value):
|
||||
"""Clause-level set: survives mid-line properties and semicolons in literals."""
|
||||
pat = re.compile(r'(^%s a pr:\w+ ;)(.*?)(\.\s*\n)' % re.escape(subject), re.S | re.M)
|
||||
m = pat.search(text)
|
||||
if not m:
|
||||
return text, False
|
||||
kept = [c for c in clauses(m.group(2))
|
||||
if c.strip() and not re.match(r'\s*%s\s' % re.escape(prop), c)]
|
||||
if value is not None:
|
||||
kept.insert(0, "\n %s %s " % (prop, value))
|
||||
body = " ;".join(kept).rstrip() + "\n "
|
||||
return text[:m.start()] + m.group(1) + body + m.group(3) + text[m.end():], True
|
||||
|
||||
|
||||
def get_prop(text, subject, prop):
|
||||
m = re.search(r'^%s a pr:\w+ ;(.*?)\.\s*\n' % re.escape(subject), text, re.S | re.M)
|
||||
if not m:
|
||||
return None
|
||||
for c in clauses(m.group(1)):
|
||||
mm = re.match(r'\s*%s\s+(.*)$' % re.escape(prop), c, re.S)
|
||||
if mm:
|
||||
return mm.group(1).strip()
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
apply_changes = "--apply" in sys.argv
|
||||
if not os.path.exists(TTL):
|
||||
print("Not found: %s" % TTL); sys.exit(2)
|
||||
text = original = open(TTL, encoding="utf-8").read()
|
||||
report = []
|
||||
|
||||
# ---- 1. domain owners -------------------------------------------------
|
||||
todo = [o for o in OWNERS if not re.search(r'^%s a ' % re.escape(o[0]), text, re.M)]
|
||||
if todo:
|
||||
blocks = "\n".join('%s a pr:DataDomainOwner ; pr:hasName "%s" .' % (i, n)
|
||||
for i, n, _ in todo)
|
||||
anchor = re.search(r'^ex:ST_\w+ a pr:DataSteward', text, re.M)
|
||||
pos = anchor.start() if anchor else 0
|
||||
text = (text[:pos]
|
||||
+ "# --- data domain owners ----------------------------------------------\n"
|
||||
+ "# Accountable for the domain. Distinct from the DGL, who runs its\n"
|
||||
+ "# governance: two roles that hasDGL alone was conflating.\n"
|
||||
+ blocks + "\n\n" + text[pos:])
|
||||
for i, n, dd in OWNERS:
|
||||
text, _ = set_prop(text, dd, "pr:hasDomainOwner", i)
|
||||
report.append("%d data domain owners named and linked" % len(OWNERS))
|
||||
|
||||
# ---- 2. physical location out of hasSource ----------------------------
|
||||
n_do = 0
|
||||
for m in list(re.finditer(r'^(ex:DO_\w+) a pr:DataObject ;', text, re.M)):
|
||||
subj = m.group(1)
|
||||
src = get_prop(text, subj, "pr:hasSource")
|
||||
if src and "/" in src:
|
||||
system, relation = [p.strip().strip('"') for p in src.strip('"').split("/", 1)]
|
||||
text, _ = set_prop(text, subj, "pr:hasSource", '"%s"' % system)
|
||||
text, _ = set_prop(text, subj, "pr:physicalName", '"%s"' % relation)
|
||||
n_do += 1
|
||||
report.append("%d data objects: physical relation moved out of hasSource" % n_do)
|
||||
|
||||
n_de = 0
|
||||
for old, new in SOURCE_FIX.items():
|
||||
text, k = re.subn(r'pr:hasSource "%s"' % re.escape(old),
|
||||
'pr:hasSource "%s"' % new, text)
|
||||
n_de += k
|
||||
report.append("%d source labels normalised to the system of origin" % n_de)
|
||||
|
||||
# ---- 3. metric units, recomputed from the elements ---------------------
|
||||
de_unit = {}
|
||||
for m in re.finditer(r'^(ex:DE_\w+) a pr:DataElement ;(.*?)\.\s*\n', text, re.S | re.M):
|
||||
u = re.search(r'pr:hasUnit\s+"([^"]*)"', m.group(2))
|
||||
if u:
|
||||
de_unit[m.group(1)] = u.group(1)
|
||||
wired = {}
|
||||
for m in re.finditer(r'(ex:M_\w+)\s+pr:computedBy(.*?)\.', text, re.S):
|
||||
wired[m.group(1)] = re.findall(r'ex:DE_\w+', m.group(2))
|
||||
n_m = 0
|
||||
for metric, des in wired.items():
|
||||
units = sorted({de_unit[d] for d in des if d in de_unit and de_unit[d] != "-"})
|
||||
if not units:
|
||||
continue
|
||||
value = " , ".join('"%s"' % u for u in units)
|
||||
before = get_prop(text, metric, "pr:hasUnit")
|
||||
text, ok = set_prop(text, metric, "pr:hasUnit", value)
|
||||
if ok and before != value:
|
||||
n_m += 1
|
||||
report.append("%d metrics now list every unit their elements use" % n_m)
|
||||
|
||||
# ---- 4. rename --------------------------------------------------------
|
||||
for subj, (old, new) in RENAME.items():
|
||||
if get_prop(text, subj, "pr:hasName") == '"%s"' % old:
|
||||
text, _ = set_prop(text, subj, "pr:hasName", '"%s"' % new)
|
||||
report.append("renamed %s -> %s" % (old, new))
|
||||
|
||||
# ---- report -----------------------------------------------------------
|
||||
print()
|
||||
print("SODH DATA FIXES v1.2 %s" % ("APPLY" if apply_changes else "DRY RUN"))
|
||||
print("=" * W)
|
||||
for line in report:
|
||||
print(" " + line)
|
||||
print("=" * W)
|
||||
multi = len(re.findall(r'pr:hasUnit\s+"[^"]*"\s*,', text))
|
||||
phys = len(re.findall(r'^ex:DO_\w+ a pr:DataObject ;(?:(?!\.\s*\n).)*?physicalName',
|
||||
text, re.S | re.M))
|
||||
doubled = []
|
||||
for m in re.finditer(r'^(ex:\w+) a pr:\w+ ;(.*?)\.\s*\n', text, re.S | re.M):
|
||||
for p in ("pr:hasName", "pr:hasSource", "pr:physicalName", "pr:hasDomainOwner"):
|
||||
if len(re.findall(r'(?<![\w:])%s\s' % re.escape(p), m.group(2))) > 1:
|
||||
doubled.append("%s/%s" % (m.group(1), p))
|
||||
print(" metrics with several units %d | data objects with a physical name %d"
|
||||
% (multi, phys))
|
||||
print(" duplicated single-valued properties: %s"
|
||||
% (", ".join(doubled) if doubled else "none"))
|
||||
print("=" * W)
|
||||
|
||||
if text != original and apply_changes:
|
||||
shutil.copy2(TTL, TTL + ".bak")
|
||||
open(TTL, "w", encoding="utf-8").write(text)
|
||||
print(" written, backup at %s.bak" % os.path.basename(TTL))
|
||||
elif text != original:
|
||||
print(" dry run -- re-run with --apply to write")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
File diff suppressed because it is too large
Load Diff
+1074
-750
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,207 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SODH - migration v1.1 -> v1.2
|
||||
==============================
|
||||
USAGE
|
||||
python3 scripts/migrate_instances_v1_2.py # dry run
|
||||
python3 scripts/migrate_instances_v1_2.py --apply # rewrite, .bak kept
|
||||
|
||||
WHAT IT DOES
|
||||
1. physicalizedIn -> storedIn everywhere (no instances yet, done for
|
||||
completeness so the term never appears again).
|
||||
2. hasSource removed from every Business Concept. A concept has no source
|
||||
of truth: its authority is its owning domain, its definition belongs in
|
||||
the glossary. Asking which system defines it has no answer, because
|
||||
every system that uses it would be a candidate.
|
||||
3. hasSource on Metrics recomputed from the elements that implement them.
|
||||
It said "SODH back-doc v0.7" -- the provenance of the record, not the
|
||||
source of the data. Asserted rather than derived, by exception, because
|
||||
"where can I get this metric" is a first-order question and the
|
||||
derivation chain will have gaps until harvesting; a shape then checks
|
||||
the assertion against the elements.
|
||||
4. The SODH Data Product, its contract and its two interfaces.
|
||||
|
||||
WHY THE PRODUCT OWNER IS EMPTY
|
||||
Nobody is appointed. The field stays absent and the shape reports a
|
||||
warning rather than a violation. Inventing a name to satisfy a blocking
|
||||
rule is exactly how BR-004 produced padding in v0.6.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
TTL = os.path.join(REPO, "instances", "sodh.ttl")
|
||||
W = 78
|
||||
|
||||
PRODUCT = "ex:DP_06_01_001"
|
||||
CONTRACT = "ex:DC_06_01_001"
|
||||
IFACE_WH = "ex:DI_06_01_001"
|
||||
IFACE_FILE = "ex:DI_06_01_002"
|
||||
|
||||
|
||||
def clauses(body):
|
||||
out, buf, i, n = [], [], 0, len(body)
|
||||
while i < n:
|
||||
c = body[i]
|
||||
if c == '"':
|
||||
j = i + 1
|
||||
while j < n and body[j] != '"':
|
||||
j += 2 if body[j] == "\\" else 1
|
||||
j = min(j + 1, n)
|
||||
buf.append(body[i:j]); i = j; continue
|
||||
if c == ";":
|
||||
out.append("".join(buf)); buf = []; i += 1; continue
|
||||
buf.append(c); i += 1
|
||||
out.append("".join(buf))
|
||||
return out
|
||||
|
||||
|
||||
def set_prop(text, subject, prop, value):
|
||||
pat = re.compile(r'(^%s a pr:\w+ ;)(.*?)(\.\s*\n)' % re.escape(subject), re.S | re.M)
|
||||
m = pat.search(text)
|
||||
if not m:
|
||||
return text, False
|
||||
kept = [c for c in clauses(m.group(2))
|
||||
if c.strip() and not re.match(r'\s*%s\s' % re.escape(prop), c)]
|
||||
if value is not None:
|
||||
kept.insert(0, "\n %s %s " % (prop, value))
|
||||
body = " ;".join(kept).rstrip() + "\n "
|
||||
return text[:m.start()] + m.group(1) + body + m.group(3) + text[m.end():], True
|
||||
|
||||
|
||||
def get_prop(text, subject, prop):
|
||||
m = re.search(r'^%s a pr:\w+ ;(.*?)\.\s*\n' % re.escape(subject), text, re.S | re.M)
|
||||
if not m:
|
||||
return None
|
||||
for c in clauses(m.group(1)):
|
||||
mm = re.match(r'\s*%s\s+(.*)$' % re.escape(prop), c, re.S)
|
||||
if mm:
|
||||
return mm.group(1).strip()
|
||||
return None
|
||||
|
||||
|
||||
def product_blocks(objects):
|
||||
packages = " ,\n ".join(objects)
|
||||
return """# --- data product ------------------------------------------------------
|
||||
# The unit of delivery: what carries a version, an owner, a changelog and a
|
||||
# list of consumers to warn. It has no single technical counterpart on purpose
|
||||
# -- rename the schema and the product is unchanged; change its SLA and it is
|
||||
# not. Its physical footprint is derivable through packages, never asserted.
|
||||
|
||||
%s a pr:DataProduct ;
|
||||
pr:hasIdentifier "DP-06.01-001" ; pr:hasName "Sell Out Data Hub - Gold" ;
|
||||
pr:owningDomain ex:DD_06 ;
|
||||
pr:operatedBy ex:SD_06_01 ;
|
||||
pr:packages %s ;
|
||||
pr:governedBy %s ;
|
||||
pr:exposes %s , %s ;
|
||||
pr:hasStatus "DRAFT" ; pr:hasVersion "1.2" ; pr:hasSource "SODH Gold" .
|
||||
|
||||
%s a pr:DataContract ;
|
||||
pr:hasIdentifier "DC-06.01-001" ; pr:hasName "Sell Out Data Hub - Gold service commitment" ;
|
||||
pr:owningDomain ex:DD_06 ;
|
||||
pr:hasBusinessRule "Refreshed weekly, available Tuesday 06:00 CET. Panel coverage published with every load. Schema stable within a minor version; 60 days notice on any breaking change. Support through the Sales Performance data team." ;
|
||||
pr:hasStatus "DRAFT" ; pr:hasVersion "1.2" .
|
||||
|
||||
%s a pr:DataInterface ;
|
||||
pr:hasIdentifier "DI-06.01-001" ; pr:hasName "SODH Gold consumption schema" ;
|
||||
pr:owningDomain ex:DD_06 ;
|
||||
pr:hasBusinessDefinition "Read access to the Gold layer through Snowflake grants. The channel BI tools and analysts consume."@en ;
|
||||
pr:hasStatus "DRAFT" ; pr:hasVersion "1.2" ; pr:hasSource "SODH Gold" .
|
||||
|
||||
%s a pr:DataInterface ;
|
||||
pr:hasIdentifier "DI-06.01-002" ; pr:hasName "Panel partner weekly extract" ;
|
||||
pr:owningDomain ex:DD_06 ;
|
||||
pr:hasBusinessDefinition "File extract delivered to the panel provider each week. Outside Snowflake, and the boundary where lineage leaves the warehouse."@en ;
|
||||
pr:hasStatus "DRAFT" ; pr:hasVersion "1.2" ; pr:hasSource "SODH Gold" .
|
||||
""" % (PRODUCT, packages, CONTRACT, IFACE_WH, IFACE_FILE,
|
||||
CONTRACT, IFACE_WH, IFACE_FILE)
|
||||
|
||||
|
||||
def main():
|
||||
apply_changes = "--apply" in sys.argv
|
||||
if not os.path.exists(TTL):
|
||||
print("Not found: %s" % TTL); sys.exit(2)
|
||||
text = original = open(TTL, encoding="utf-8").read()
|
||||
report = []
|
||||
|
||||
# 1. term rename
|
||||
text, n = re.subn(r'\bpr:physicalizedIn\b', 'pr:storedIn', text)
|
||||
report.append("physicalizedIn -> storedIn: %d occurrence(s)" % n)
|
||||
|
||||
# 2. no source of truth on a concept
|
||||
n_bc = 0
|
||||
for m in list(re.finditer(r'^(ex:BC_\w+) a pr:BusinessConcept ;', text, re.M)):
|
||||
if get_prop(text, m.group(1), "pr:hasSource") is not None:
|
||||
text, _ = set_prop(text, m.group(1), "pr:hasSource", None)
|
||||
n_bc += 1
|
||||
report.append("hasSource removed from %d business concepts" % n_bc)
|
||||
|
||||
# 3. metric source of truth, from the elements that implement it
|
||||
de_src = {}
|
||||
for m in re.finditer(r'^(ex:DE_\w+) a pr:DataElement ;(.*?)\.\s*\n', text, re.S | re.M):
|
||||
v = re.search(r'pr:hasSource\s+"([^"]*)"', m.group(2))
|
||||
if v:
|
||||
de_src[m.group(1)] = v.group(1)
|
||||
wired = {}
|
||||
for m in re.finditer(r'(ex:M_\w+)\s+pr:computedBy(.*?)\.', text, re.S):
|
||||
wired[m.group(1)] = re.findall(r'ex:DE_\w+', m.group(2))
|
||||
n_m, mixed = 0, []
|
||||
for metric, des in wired.items():
|
||||
srcs = sorted({de_src[d] for d in des if d in de_src})
|
||||
if not srcs:
|
||||
continue
|
||||
if len(srcs) > 1:
|
||||
mixed.append(metric)
|
||||
text, ok = set_prop(text, metric, "pr:hasSource",
|
||||
" , ".join('"%s"' % x for x in srcs))
|
||||
n_m += ok
|
||||
report.append("source of truth recomputed on %d metrics%s"
|
||||
% (n_m, "" if not mixed else
|
||||
" (%d blend several systems)" % len(mixed)))
|
||||
|
||||
# 4. the data product
|
||||
if not re.search(r'^%s a ' % re.escape(PRODUCT), text, re.M):
|
||||
objs = re.findall(r'^(ex:DO_\w+) a pr:DataObject ;', text, re.M)
|
||||
text = text.rstrip() + "\n\n\n" + product_blocks(objs)
|
||||
report.append("data product created, packaging %d data objects" % len(objs))
|
||||
else:
|
||||
report.append("data product already present, skipped")
|
||||
|
||||
# ---- report
|
||||
print()
|
||||
print("SODH MIGRATION v1.1 -> v1.2 %s" % ("APPLY" if apply_changes else "DRY RUN"))
|
||||
print("=" * W)
|
||||
for line in report:
|
||||
print(" " + line)
|
||||
print("=" * W)
|
||||
bc_src = len(re.findall(r'^ex:BC_\w+ a pr:BusinessConcept ;(?:(?!\.\s*\n).)*?hasSource',
|
||||
text, re.S | re.M))
|
||||
defined = set(re.findall(r'^(ex:\w+) a ', text, re.M))
|
||||
dangling = sorted(set(re.findall(r'\bex:\w+', text)) - defined)
|
||||
doubled = []
|
||||
for m in re.finditer(r'^(ex:\w+) a pr:\w+ ;(.*?)\.\s*\n', text, re.S | re.M):
|
||||
for p in ("pr:hasName", "pr:hasSource", "pr:operatedBy", "pr:governedBy"):
|
||||
if len(re.findall(r'(?<![\w:])%s\s' % re.escape(p), m.group(2))) > 1:
|
||||
doubled.append("%s/%s" % (m.group(1), p))
|
||||
print(" concepts still carrying a source: %d (must be 0)" % bc_src)
|
||||
print(" physicalizedIn left: %d (must be 0)"
|
||||
% len(re.findall(r'pr:physicalizedIn', text)))
|
||||
print(" dangling references: %s" % (", ".join(dangling) if dangling else "none"))
|
||||
print(" duplicated single-valued properties: %s"
|
||||
% (", ".join(doubled) if doubled else "none"))
|
||||
print("=" * W)
|
||||
|
||||
if text != original and apply_changes:
|
||||
shutil.copy2(TTL, TTL + ".bak")
|
||||
open(TTL, "w", encoding="utf-8").write(text)
|
||||
print(" written, backup at %s.bak" % os.path.basename(TTL))
|
||||
elif text != original:
|
||||
print(" dry run -- re-run with --apply to write")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SODH - migration v1.2 -> v1.3
|
||||
==============================
|
||||
USAGE
|
||||
python3 scripts/migrate_instances_v1_3.py # dry run
|
||||
python3 scripts/migrate_instances_v1_3.py --apply # rewrite, .bak kept
|
||||
|
||||
1. references -> qualifiedBy. The name now says why the link exists rather
|
||||
than how it is implemented.
|
||||
|
||||
2. hasSource removed from every Business Object. Same argument as for the
|
||||
Business Concepts in v1.2, and the values showed why it was needed: across
|
||||
the 15 objects the property held physical locations ("SODH Gold /
|
||||
F_SELL_OUT"), migration notes ("MDM Product -> SODH [concepts TBC by
|
||||
DD-10]") and arbitration remarks ("DGO proposal, pending ratification"),
|
||||
all under one name. A Business Object is a governance grouping; its data
|
||||
lives in the Data Objects that represent it, and those carry the system.
|
||||
|
||||
3. Short labels where the long name is unwieldy on screen. The Data Product
|
||||
was called "Sell Out Data Hub - Gold" on its own card and "SODH Gold"
|
||||
everywhere else, because the viewers each kept a display dictionary.
|
||||
|
||||
4. Instance versions aligned on the model version. Business Objects were
|
||||
still stamped 0.6 while the model had moved to 1.3.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
TTL = os.path.join(REPO, "instances", "sodh.ttl")
|
||||
W = 78
|
||||
|
||||
SHORT_LABELS = {
|
||||
"ex:DP_06_01_001": "SODH Gold",
|
||||
"ex:DC_06_01_001": "SODH Gold contract",
|
||||
"ex:DI_06_01_001": "Consumption schema",
|
||||
"ex:DI_06_01_002": "Panel extract",
|
||||
"ex:DO_06_01_001": "Sell Out Volume",
|
||||
"ex:DO_06_01_003": "Sell Out Distribution",
|
||||
"ex:DO_10_01_001": "Product",
|
||||
"ex:DO_04_01_001": "Customer",
|
||||
"ex:DO_16_01_001": "Currency",
|
||||
"ex:DO_21_01_001": "Calendar",
|
||||
}
|
||||
MODEL_VERSION = "1.3"
|
||||
|
||||
|
||||
def clauses(body):
|
||||
out, buf, i, n = [], [], 0, len(body)
|
||||
while i < n:
|
||||
c = body[i]
|
||||
if c == '"':
|
||||
j = i + 1
|
||||
while j < n and body[j] != '"':
|
||||
j += 2 if body[j] == "\\" else 1
|
||||
j = min(j + 1, n)
|
||||
buf.append(body[i:j]); i = j; continue
|
||||
if c == ";":
|
||||
out.append("".join(buf)); buf = []; i += 1; continue
|
||||
buf.append(c); i += 1
|
||||
out.append("".join(buf))
|
||||
return out
|
||||
|
||||
|
||||
def set_prop(text, subject, prop, value):
|
||||
pat = re.compile(r'(^%s a pr:\w+ ;)(.*?)(\.\s*\n)' % re.escape(subject), re.S | re.M)
|
||||
m = pat.search(text)
|
||||
if not m:
|
||||
return text, False
|
||||
kept = [c for c in clauses(m.group(2))
|
||||
if c.strip() and not re.match(r'\s*%s\s' % re.escape(prop), c)]
|
||||
if value is not None:
|
||||
kept.insert(0, "\n %s %s " % (prop, value))
|
||||
body = " ;".join(kept).rstrip() + "\n "
|
||||
return text[:m.start()] + m.group(1) + body + m.group(3) + text[m.end():], True
|
||||
|
||||
|
||||
def has_prop(text, subject, prop):
|
||||
m = re.search(r'^%s a pr:\w+ ;(.*?)\.\s*\n' % re.escape(subject), text, re.S | re.M)
|
||||
return bool(m) and any(re.match(r'\s*%s\s' % re.escape(prop), c)
|
||||
for c in clauses(m.group(1)))
|
||||
|
||||
|
||||
def main():
|
||||
apply_changes = "--apply" in sys.argv
|
||||
if not os.path.exists(TTL):
|
||||
print("Not found: %s" % TTL); sys.exit(2)
|
||||
text = original = open(TTL, encoding="utf-8").read()
|
||||
report = []
|
||||
|
||||
text, n = re.subn(r'\bpr:references\b', 'pr:qualifiedBy', text)
|
||||
report.append("references -> qualifiedBy: %d occurrence(s)" % n)
|
||||
|
||||
n_bo = 0
|
||||
for m in list(re.finditer(r'^(ex:BO_\w+) a pr:BusinessObject ;', text, re.M)):
|
||||
if has_prop(text, m.group(1), "pr:hasSource"):
|
||||
text, _ = set_prop(text, m.group(1), "pr:hasSource", None)
|
||||
n_bo += 1
|
||||
report.append("hasSource removed from %d business objects" % n_bo)
|
||||
|
||||
n_sl = 0
|
||||
for subj, label in SHORT_LABELS.items():
|
||||
if re.search(r'^%s a ' % re.escape(subj), text, re.M):
|
||||
text, ok = set_prop(text, subj, "pr:hasShortLabel", '"%s"' % label)
|
||||
n_sl += ok
|
||||
report.append("short label set on %d objects" % n_sl)
|
||||
|
||||
n_v = 0
|
||||
for m in list(re.finditer(r'^(ex:\w+) a pr:\w+ ;', text, re.M)):
|
||||
if has_prop(text, m.group(1), "pr:hasVersion"):
|
||||
text, ok = set_prop(text, m.group(1), "pr:hasVersion",
|
||||
'"%s"' % MODEL_VERSION)
|
||||
n_v += ok
|
||||
report.append("version aligned on %s for %d objects" % (MODEL_VERSION, n_v))
|
||||
|
||||
print()
|
||||
print("SODH MIGRATION v1.2 -> v1.3 %s" % ("APPLY" if apply_changes else "DRY RUN"))
|
||||
print("=" * W)
|
||||
for line in report:
|
||||
print(" " + line)
|
||||
print("=" * W)
|
||||
left_bo = len([1 for m in re.finditer(r'^(ex:BO_\w+) a pr:BusinessObject ;', text, re.M)
|
||||
if has_prop(text, m.group(1), "pr:hasSource")])
|
||||
doubled = []
|
||||
for m in re.finditer(r'^(ex:\w+) a pr:\w+ ;(.*?)\.\s*\n', text, re.S | re.M):
|
||||
for p in ("pr:hasName", "pr:hasShortLabel", "pr:hasVersion", "pr:hasSource"):
|
||||
if len(re.findall(r'(?<![\w:])%s\s' % re.escape(p), m.group(2))) > 1:
|
||||
doubled.append("%s/%s" % (m.group(1), p))
|
||||
print(" business objects still carrying a source: %d (must be 0)" % left_bo)
|
||||
print(" references left: %d (must be 0)" % len(re.findall(r'pr:references', text)))
|
||||
print(" duplicated single-valued properties: %s"
|
||||
% (", ".join(doubled) if doubled else "none"))
|
||||
print("=" * W)
|
||||
|
||||
if text != original and apply_changes:
|
||||
shutil.copy2(TTL, TTL + ".bak")
|
||||
open(TTL, "w", encoding="utf-8").write(text)
|
||||
print(" written, backup at %s.bak" % os.path.basename(TTL))
|
||||
elif text != original:
|
||||
print(" dry run -- re-run with --apply to write")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,176 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SODH - migration v1.3 -> v1.4
|
||||
==============================
|
||||
USAGE
|
||||
python3 scripts/migrate_instances_v1_4.py # dry run
|
||||
python3 scripts/migrate_instances_v1_4.py --apply # rewrite, .bak kept
|
||||
|
||||
1. SYSTEMS BECOME NODES. hasSource held a string: "SODH Gold", "MDM Product",
|
||||
"Group Finance". Six systems are created and sourcedFrom points at them.
|
||||
"Which objects depend on MDM Product?" was unanswerable while MDM Product
|
||||
was text.
|
||||
|
||||
The systems are seeded here by hand, once. Everything below them --
|
||||
databases, schemas, tables, columns -- is meant to be harvested, and this
|
||||
script does not invent any of it.
|
||||
|
||||
2. Three hasSource values were not systems at all but migration notes ("DGO
|
||||
proposal, split of a compound sub-domain"). They are dropped rather than
|
||||
turned into a system: provenance of a record is not a property of the thing
|
||||
the record describes.
|
||||
|
||||
3. materializedAs -> storedIn on the Data Objects. Nothing carries it yet,
|
||||
done for completeness so the term never reappears.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
TTL = os.path.join(REPO, "instances", "sodh.ttl")
|
||||
W = 78
|
||||
|
||||
# (iri, identifier, name, short label, system type, the string it replaces)
|
||||
SYSTEMS = [
|
||||
("ex:SYS_SODH_GOLD", "SYS-001", "Sell Out Data Hub - Gold layer", "SODH Gold",
|
||||
"pr:DataPlatform", "SODH Gold"),
|
||||
("ex:SYS_MDM_PRODUCT", "SYS-002", "Master Data Management - Product", "MDM Product",
|
||||
"pr:MasterDataSystem", "MDM Product"),
|
||||
("ex:SYS_MDM_CUSTOMER", "SYS-003", "Master Data Management - Customer", "MDM Customer",
|
||||
"pr:MasterDataSystem", "MDM Customer"),
|
||||
("ex:SYS_GROUP_FINANCE", "SYS-004", "Group Finance consolidation", "Group Finance",
|
||||
"pr:SourceApplication", "Group Finance"),
|
||||
("ex:SYS_CORPORATE_CALENDAR", "SYS-005", "Corporate standard calendar", "Standard Calendar",
|
||||
"pr:SourceApplication", "Standard Calendar"),
|
||||
]
|
||||
|
||||
# strings that were never a system: provenance notes about the record itself
|
||||
NOT_A_SYSTEM = ["DGO proposal"]
|
||||
|
||||
|
||||
def clauses(body):
|
||||
out, buf, i, n = [], [], 0, len(body)
|
||||
while i < n:
|
||||
c = body[i]
|
||||
if c == '"':
|
||||
j = i + 1
|
||||
while j < n and body[j] != '"':
|
||||
j += 2 if body[j] == "\\" else 1
|
||||
j = min(j + 1, n)
|
||||
buf.append(body[i:j]); i = j; continue
|
||||
if c == ";":
|
||||
out.append("".join(buf)); buf = []; i += 1; continue
|
||||
buf.append(c); i += 1
|
||||
out.append("".join(buf))
|
||||
return out
|
||||
|
||||
|
||||
def set_prop(text, subject, prop, value):
|
||||
pat = re.compile(r'(^%s a pr:\w+ ;)(.*?)(\.\s*\n)' % re.escape(subject), re.S | re.M)
|
||||
m = pat.search(text)
|
||||
if not m:
|
||||
return text, False
|
||||
kept = [c for c in clauses(m.group(2))
|
||||
if c.strip() and not re.match(r'\s*%s\s' % re.escape(prop), c)]
|
||||
if value is not None:
|
||||
kept.insert(0, "\n %s %s " % (prop, value))
|
||||
body = " ;".join(kept).rstrip() + "\n "
|
||||
return text[:m.start()] + m.group(1) + body + m.group(3) + text[m.end():], True
|
||||
|
||||
|
||||
def get_source(text, subject):
|
||||
m = re.search(r'^%s a pr:\w+ ;(.*?)\.\s*\n' % re.escape(subject), text, re.S | re.M)
|
||||
if not m:
|
||||
return None
|
||||
for c in clauses(m.group(1)):
|
||||
mm = re.match(r'\s*pr:hasSource\s+"([^"]*)"', c)
|
||||
if mm:
|
||||
return mm.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def system_blocks(todo):
|
||||
head = ("# --- systems -----------------------------------------------------------\n"
|
||||
"# Seeded by hand, once. A system was a string until now, which is why\n"
|
||||
"# 'what depends on MDM Product' had no answer. Everything below a system --\n"
|
||||
"# databases, schemas, tables, columns -- is meant to be harvested, and\n"
|
||||
"# nothing here invents any of it.\n\n")
|
||||
out = []
|
||||
for iri, ident, name, short, stype, _ in todo:
|
||||
out.append('%s a pr:System ;\n'
|
||||
' pr:hasIdentifier "%s" ; pr:hasName "%s" ;\n'
|
||||
' pr:hasShortLabel "%s" ;\n'
|
||||
' pr:hasSystemType %s ;\n'
|
||||
' pr:hasStatus "DRAFT" ; pr:hasVersion "1.4" .'
|
||||
% (iri, ident, name, short, stype))
|
||||
return head + "\n".join(out) + "\n"
|
||||
|
||||
|
||||
def main():
|
||||
apply_changes = "--apply" in sys.argv
|
||||
if not os.path.exists(TTL):
|
||||
print("Not found: %s" % TTL); sys.exit(2)
|
||||
text = original = open(TTL, encoding="utf-8").read()
|
||||
report = []
|
||||
|
||||
todo = [sy for sy in SYSTEMS if not re.search(r'^%s a ' % re.escape(sy[0]), text, re.M)]
|
||||
if todo:
|
||||
anchor = re.search(r'^ex:DD_\w+ a pr:DataDomain', text, re.M)
|
||||
pos = anchor.start() if anchor else 0
|
||||
text = text[:pos] + system_blocks(todo) + "\n" + text[pos:]
|
||||
report.append("%d systems created%s" % (len(todo), "" if todo else " (already present)"))
|
||||
|
||||
by_string = {sy[5]: sy[0] for sy in SYSTEMS}
|
||||
n_ok = n_drop = 0
|
||||
for m in list(re.finditer(r'^(ex:\w+) a pr:\w+ ;', text, re.M)):
|
||||
subj = m.group(1)
|
||||
src = get_source(text, subj)
|
||||
if src is None:
|
||||
continue
|
||||
if src in by_string:
|
||||
text, _ = set_prop(text, subj, "pr:hasSource", None)
|
||||
text, _ = set_prop(text, subj, "pr:sourcedFrom", by_string[src])
|
||||
n_ok += 1
|
||||
elif any(k in src for k in NOT_A_SYSTEM):
|
||||
text, _ = set_prop(text, subj, "pr:hasSource", None)
|
||||
n_drop += 1
|
||||
report.append("sourcedFrom set on %d objects" % n_ok)
|
||||
report.append("%d provenance notes dropped rather than turned into a system" % n_drop)
|
||||
|
||||
text, n = re.subn(r'\bpr:materializedAs\b', 'pr:storedIn', text)
|
||||
report.append("materializedAs -> storedIn: %d occurrence(s)" % n)
|
||||
|
||||
print()
|
||||
print("SODH MIGRATION v1.3 -> v1.4 %s" % ("APPLY" if apply_changes else "DRY RUN"))
|
||||
print("=" * W)
|
||||
for line in report:
|
||||
print(" " + line)
|
||||
print("=" * W)
|
||||
left = re.findall(r'pr:hasSource\s+"([^"]*)"', text)
|
||||
defined = set(re.findall(r'^(ex:\w+) a ', text, re.M))
|
||||
dangling = sorted(set(re.findall(r'\bex:\w+', text)) - defined)
|
||||
doubled = []
|
||||
for m in re.finditer(r'^(ex:\w+) a pr:\w+ ;(.*?)\.\s*\n', text, re.S | re.M):
|
||||
for p in ("pr:sourcedFrom", "pr:hasName", "pr:hasShortLabel"):
|
||||
if len(re.findall(r'(?<![\w:])%s\s' % re.escape(p), m.group(2))) > 1:
|
||||
doubled.append("%s/%s" % (m.group(1), p))
|
||||
print(" hasSource left: %d %s" % (len(left), sorted(set(left)) if left else "(must be 0)"))
|
||||
print(" sourcedFrom references: %d" % len(re.findall(r'pr:sourcedFrom', text)))
|
||||
print(" dangling references: %s" % (", ".join(dangling) if dangling else "none"))
|
||||
print(" duplicated single-valued properties: %s"
|
||||
% (", ".join(doubled) if doubled else "none"))
|
||||
print("=" * W)
|
||||
|
||||
if text != original and apply_changes:
|
||||
shutil.copy2(TTL, TTL + ".bak")
|
||||
open(TTL, "w", encoding="utf-8").write(text)
|
||||
print(" written, backup at %s.bak" % os.path.basename(TTL))
|
||||
elif text != original:
|
||||
print(" dry run -- re-run with --apply to write")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+103
-26
@@ -13,8 +13,8 @@
|
||||
# ----------------------
|
||||
# 1. SPLIT BY PROVENANCE. v0.1.1 targeted pr:MetaModelObject and demanded an
|
||||
# identifier, a name, an owner, an owning domain, a status and a version on
|
||||
# everything. Applied to the harvested half of the graph that would fail on
|
||||
# every one of ~50 000 Snowflake columns. Curated and Observed objects now
|
||||
# everything. Applied to the captured half of the graph that would fail on
|
||||
# every one of ~50 000 Snowflake columns. Defined and Captured objects now
|
||||
# have separate shapes with separate expectations.
|
||||
#
|
||||
# 2. SCOPE FOR THE UNIFIED RELATIONS. belongsTo and represents deliberately
|
||||
@@ -40,29 +40,29 @@
|
||||
|
||||
<https://ontology.pernod-ricard.com/metamodel/shapes/>
|
||||
dcterms:title "PR Data Meta Model - SHACL Shapes" ;
|
||||
dcterms:modified "2026-07-26"^^xsd:date ;
|
||||
dcterms:modified "2026-07-30"^^xsd:date ;
|
||||
rdfs:comment "Executable form of the rulebook. Validated by scripts/run_shacl_validation.py." .
|
||||
|
||||
|
||||
#################################################################
|
||||
# IDENTITY AND LIFECYCLE -- curated objects only
|
||||
# IDENTITY AND LIFECYCLE -- defined objects only
|
||||
#################################################################
|
||||
|
||||
prs:CuratedObjectShape a sh:NodeShape ;
|
||||
sh:targetClass pr:CuratedObject ;
|
||||
rdfs:comment "Applies to everything governance asserts. Observed objects are deliberately exempt: see ObservedObjectShape." ;
|
||||
prs:DefinedObjectShape a sh:NodeShape ;
|
||||
sh:targetClass pr:DefinedObject ;
|
||||
rdfs:comment "Applies to everything governance writes. Captured objects are deliberately exempt: see CapturedObjectShape." ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:hasIdentifier ; sh:datatype xsd:string ;
|
||||
sh:minCount 1 ; sh:maxCount 1 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "DQ-001 -- every curated object carries exactly one identifier. NOTE: uniqueness across the graph is NOT tested here; SHACL checks cardinality only. The reconciliation job tests uniqueness." ] ;
|
||||
sh:message "DQ-001 -- every defined object carries exactly one identifier. NOTE: uniqueness across the graph is NOT tested here; SHACL checks cardinality only. The reconciliation job tests uniqueness." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:hasName ; sh:datatype xsd:string ;
|
||||
sh:minCount 1 ; sh:maxCount 1 ; sh:minLength 3 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "Every curated object carries exactly one canonical name." ] ;
|
||||
sh:message "Every defined object carries exactly one canonical name." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:hasStatus ; sh:minCount 1 ;
|
||||
@@ -82,7 +82,7 @@ prs:CuratedObjectShape a sh:NodeShape ;
|
||||
|
||||
|
||||
prs:PublishedShape a sh:NodeShape ;
|
||||
sh:targetClass pr:CuratedObject ;
|
||||
sh:targetClass pr:DefinedObject ;
|
||||
rdfs:comment "Extra demands that only bite once an object claims to be PUBLISHED. Keeping these off the base shape is what lets a domain be documented progressively." ;
|
||||
|
||||
sh:sparql [
|
||||
@@ -107,11 +107,11 @@ prs:PublishedShape a sh:NodeShape ;
|
||||
|
||||
|
||||
#################################################################
|
||||
# OBSERVED OBJECTS -- harvested, never hand-edited
|
||||
# OBSERVED OBJECTS -- captured, never hand-edited
|
||||
#################################################################
|
||||
|
||||
prs:ObservedObjectShape a sh:NodeShape ;
|
||||
sh:targetClass pr:ObservedObject ;
|
||||
prs:CapturedObjectShape a sh:NodeShape ;
|
||||
sh:targetClass pr:CapturedObject ;
|
||||
rdfs:comment "No identifier, no name, no owner, no status, no version. A harvested column is attributed through the Data Element mapped to it, never asserted directly. What it must carry is enough to be re-found on the next run." ;
|
||||
|
||||
sh:property [
|
||||
@@ -124,12 +124,26 @@ prs:ObservedObjectShape a sh:NodeShape ;
|
||||
sh:path pr:harvestedOn ; sh:datatype xsd:dateTime ;
|
||||
sh:minCount 1 ; sh:maxCount 1 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "Every observed object records when it was harvested. Without it there is no way to tell a current fact from a stale one." ] ;
|
||||
sh:message "Every captured object records when it was harvested. Without it there is no way to tell a current fact from a stale one." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:owningDomain ; sh:maxCount 0 ;
|
||||
sh:severity sh:Warning ;
|
||||
sh:message "Observed objects are not attributed directly -- ownership flows from the Data Element mapped to them." ] .
|
||||
sh:message "Captured objects are not attributed directly -- ownership flows from the Data Element mapped to them." ] .
|
||||
|
||||
|
||||
# inSchema is deliberately NOT required anywhere. Neo4j has no schema and
|
||||
# BigQuery calls the level a dataset; a minCount 1 here would break on the
|
||||
# first harvest outside Snowflake.
|
||||
prs:DataStructureShape a sh:NodeShape ;
|
||||
sh:targetClass pr:DataStructure ;
|
||||
sh:property [
|
||||
sh:path pr:inSchema ; sh:maxCount 1 ;
|
||||
sh:severity sh:Info ;
|
||||
sh:message "Optional on purpose: not every engine has a schema level." ] ;
|
||||
sh:property [
|
||||
sh:path pr:sourcedFrom ; sh:maxCount 1 ;
|
||||
sh:severity sh:Info ] .
|
||||
|
||||
|
||||
prs:FieldShape a sh:NodeShape ;
|
||||
@@ -211,7 +225,12 @@ prs:BusinessObjectShape a sh:NodeShape ;
|
||||
sh:property [
|
||||
sh:path pr:hasBusinessDefinition ; sh:maxCount 0 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Business Object carries no definition of its own: meaning belongs to the Business Concept named by aboutConcept. Two definitions for one notion are two definitions free to diverge. MIGRATION: move the text to that Concept." ] .
|
||||
sh:message "A Business Object carries no definition of its own: meaning belongs to the Business Concept named by aboutConcept. Two definitions for one notion are two definitions free to diverge. MIGRATION: move the text to that Concept." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:sourcedFrom ; sh:maxCount 0 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Business Object has no system of truth. It is a governance grouping, not data: its data lives in the Data Objects that represent it, and those name the system. In v0.6 this property held a grab-bag on the 15 objects -- physical locations, migration notes, arbitration remarks -- all under one name." ] .
|
||||
|
||||
|
||||
#################################################################
|
||||
@@ -231,7 +250,12 @@ prs:BusinessConceptShape a sh:NodeShape ;
|
||||
sh:property [
|
||||
sh:path pr:hasFormula ; sh:maxCount 0 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "BR-003 -- the presence of a formula is what makes something a Metric. A Concept with a formula is a misclassified Metric." ] .
|
||||
sh:message "BR-003 -- the presence of a formula is what makes something a Metric. A Concept with a formula is a misclassified Metric." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:sourcedFrom ; sh:maxCount 0 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Business Concept has no system of truth. Its authority is its owning domain and its definition belongs in the glossary. Naming a system here would ask which of the systems that USE the concept defines it -- a question with no answer." ] .
|
||||
|
||||
|
||||
prs:MetricShape a sh:NodeShape ;
|
||||
@@ -244,9 +268,9 @@ prs:MetricShape a sh:NodeShape ;
|
||||
sh:message "BR-003 -- a Metric is a measurement with a calculation rule. No formula, no Metric." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:hasUnit ; sh:minCount 1 ; sh:maxCount 1 ;
|
||||
sh:path pr:hasUnit ; sh:minCount 1 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Metric states its unit." ] ;
|
||||
sh:message "A Metric states every unit its variants are expressed in. NOT capped at one: Sell Out Volume is computed in 9L and in L, Sell Out Value in EUR, USD and local currency. The single-unit rule belongs on the Data Element, where it holds -- see DataElementShape." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:measures ; sh:class pr:BusinessConcept ;
|
||||
@@ -265,6 +289,39 @@ prs:MetricShape a sh:NodeShape ;
|
||||
sh:message "A Metric must not carry a physical name -- that is a layer leak. Under BR-013 the physical name belongs on the Data Element." ] .
|
||||
|
||||
|
||||
# The source of truth of a Metric is asserted by exception, then checked.
|
||||
# "Where can I get this metric" is a first-order question and the derivation
|
||||
# chain will have gaps before harvesting, so the assertion stands on its own --
|
||||
# but it must agree with the elements that implement the metric, or the two
|
||||
# will drift the day an element moves.
|
||||
prs:MetricSourceShape a sh:NodeShape ;
|
||||
sh:targetClass pr:Metric ;
|
||||
rdfs:comment "Rewritten in v1.4 to compare System references rather than strings. A string comparison would have called 'SODH Gold' and 'Snowflake (SODH Gold)' two different systems." ;
|
||||
sh:sparql [
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Metric's system of truth must match that of at least one element computing it. If they disagree, either the metric points at the wrong system or an element has moved." ;
|
||||
sh:select """
|
||||
PREFIX pr: <https://ontology.pernod-ricard.com/metamodel/>
|
||||
SELECT $this WHERE {
|
||||
$this pr:sourcedFrom ?sys ; pr:computedBy ?de .
|
||||
FILTER NOT EXISTS {
|
||||
$this pr:computedBy ?any .
|
||||
?any pr:sourcedFrom ?sys .
|
||||
}
|
||||
}""" ] ;
|
||||
sh:sparql [
|
||||
sh:severity sh:Warning ;
|
||||
sh:message "Elements computing one Metric come from several systems. Legitimate for a metric blending sources, worth a look otherwise." ;
|
||||
sh:select """
|
||||
PREFIX pr: <https://ontology.pernod-ricard.com/metamodel/>
|
||||
SELECT $this WHERE {
|
||||
$this pr:computedBy ?a , ?b .
|
||||
?a pr:sourcedFrom ?sa .
|
||||
?b pr:sourcedFrom ?sb .
|
||||
FILTER(?sa != ?sb)
|
||||
}""" ] .
|
||||
|
||||
|
||||
# BR-013, finally executable. v0.1.1 declared it BLOCKING with no shape.
|
||||
prs:MotherMetricShape a sh:NodeShape ;
|
||||
sh:targetClass pr:Metric ;
|
||||
@@ -306,7 +363,22 @@ prs:DataObjectShape a sh:NodeShape ;
|
||||
sh:property [
|
||||
sh:path pr:monitoredBy ; sh:maxCount 0 ;
|
||||
sh:severity sh:Warning ;
|
||||
sh:message "Stewardship is declared on the Business Object and inherited through represents. Declaring it here allows two answers to the same question." ] .
|
||||
sh:message "Stewardship is declared on the Business Object and inherited through represents. Declaring it here allows two answers to the same question." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:sourcedFrom ; sh:class pr:System ; sh:maxCount 1 ;
|
||||
sh:severity sh:Warning ;
|
||||
sh:message "Name the System holding the authoritative data, as a reference rather than a string. A string could not answer 'what depends on MDM Product'." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:storedIn ; sh:class pr:DataStructure ;
|
||||
sh:severity sh:Warning ;
|
||||
sh:message "Where the object actually sits: a table, a view, later a node label. The seam between what governance defines and what a harvester captures -- proposed by the reconciliation job, confirmed by a steward." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:materializedAs ; sh:maxCount 0 ;
|
||||
sh:severity sh:Warning ;
|
||||
sh:message "Deprecated in v1.4: storedIn now serves both granularities." ] .
|
||||
|
||||
|
||||
# A declared grain element must actually belong to the object it grains.
|
||||
@@ -340,6 +412,11 @@ prs:DataElementShape a sh:NodeShape ;
|
||||
sh:path pr:fullyQualifiedName ; sh:maxCount 1 ;
|
||||
sh:severity sh:Info ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:hasUnit ; sh:maxCount 1 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Data Element carries exactly one unit. This is the counterpart of the Metric rule: the mother metric lists the units its variants use, each variant states the single unit it is actually expressed in. An element with two units is two elements." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:represents ; sh:class pr:BusinessConcept ;
|
||||
sh:maxCount 1 ;
|
||||
@@ -363,7 +440,7 @@ prs:DataElementMeaningShape a sh:NodeShape ;
|
||||
sh:minCount 1 ] ]
|
||||
) ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Data Element must reach business meaning by exactly one route: represents a Business Concept (dimensional), or be computedBy a Metric (measure). Never both, never neither. A curated column with no business meaning is debt, not an acceptable state." .
|
||||
sh:message "A Data Element must reach business meaning by exactly one route: represents a Business Concept (dimensional), or be computedBy a Metric (measure). Never both, never neither. A defined column with no business meaning is debt, not an acceptable state." .
|
||||
|
||||
|
||||
#################################################################
|
||||
@@ -381,9 +458,9 @@ prs:DataProductShape a sh:NodeShape ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:hasProductOwner ; sh:class pr:DataProductOwner ;
|
||||
sh:minCount 1 ; sh:maxCount 1 ;
|
||||
sh:severity sh:Violation ;
|
||||
sh:message "A Data Product has exactly one Product Owner." ] ;
|
||||
sh:maxCount 1 ;
|
||||
sh:severity sh:Warning ;
|
||||
sh:message "A Data Product should name exactly one Product Owner. A warning rather than a block: the SODH owner is genuinely not appointed, and a blocking rule that cannot be satisfied truthfully is how BR-004 produced padding." ] ;
|
||||
|
||||
sh:property [
|
||||
sh:path pr:packages ; sh:class pr:DataObject ;
|
||||
@@ -418,7 +495,7 @@ prs:BIFieldShape a sh:NodeShape ;
|
||||
sh:targetClass pr:BIField ;
|
||||
rdfs:comment "realizesMetric is a transitional control: asserted directly, with no rule written against the lineage chain. Making the assertion conditional on intermediate mappings existing would create confusion and discourage people from filling it in at all." ;
|
||||
sh:property [
|
||||
sh:path pr:realizesMetric ; sh:class pr:Metric ;
|
||||
sh:path pr:exposesMetric ; sh:class pr:Metric ;
|
||||
sh:maxCount 1 ;
|
||||
sh:severity sh:Info ;
|
||||
sh:message "Which certified Metric this BI field implements. Comparing expressions across fields realizing one Metric is the harmonisation measure." ] .
|
||||
@@ -429,7 +506,7 @@ prs:BIFieldShape a sh:NodeShape ;
|
||||
#################################################################
|
||||
|
||||
prs:NamingShape a sh:NodeShape ;
|
||||
sh:targetClass pr:CuratedObject ;
|
||||
sh:targetClass pr:DefinedObject ;
|
||||
sh:property [
|
||||
sh:path pr:hasName ;
|
||||
sh:not [ sh:pattern "_NM$" ] ;
|
||||
|
||||
Reference in New Issue
Block a user