其他分享
首页 > 其他分享> > DataHub: 现代数据栈的元数据平台--如何针对元数据建模?

DataHub: 现代数据栈的元数据平台--如何针对元数据建模?

作者:互联网

元数据建模概念

DataHub采用模式优先【schema-first】的方法对元数据进行建模: 使用开源的Pegasus模式语言(PDL)'扩展了一组定制的注释来针对元数据建模。

DataHub存储、服务、索引和摄取层直接在元数据模型之上操作,并支持从客户端到存储层的所有强类型。

核心抽象

从概念上讲,元数据建模 使用了以下抽象:

示意图如下:
下面的元数据图由一个由3种类型的实体(CorpUser、Chart、Dashboard)、2种类型的关系(OwnedBy、Contains) 和 3种类型的元数据方面(Ownership、ChartInfo和DashboardInfo)组成的示例图。
在这里插入图片描述

核心实体

DataHub的**“核心”实体类型**为构成现代数据栈的数据资产建模。它们包括:

实体注册(Entity Registry)

元数据模型是通过实体注册(Entity Registry)拼接在一起的。Entity Registry简单地说,这就是定义模型“模式”的地方。

Entity Registry被构建的2种方式:快照模型 、YAML配置模型。

从2022年1月起,DataHub已不支持将快照模型作为添加新实体的方法,这样元数据模型演变会变得更加容易,添加实体和方面变成了在YAML配置文件中添加配置的问题,而不是创建新的快照/方面文件。

快照模型

Snapshot models 快照模型: 显式地将实体绑定到与之相关的方面。如定义Dataset 实体时,使用DatasetSnapshotDatasetAspectDatasetProperties,这些文件的定义参见下面的源码

namespace com.linkedin.metadata.snapshot
/**
 * A metadata snapshot for a specific dataset entity.
 */
@Entity = {
  "name": "dataset",
  "keyAspect": "datasetKey"
}
record DatasetSnapshot {

  /**
   * URN for the entity the metadata snapshot is associated with.
   */
  urn: DatasetUrn

  /**
   * The list of metadata aspects associated with the dataset. Depending on the use case, this can either be all, or a selection, of supported aspects.
   */
  aspects: array[DatasetAspect]
}

namespace com.linkedin.metadata.aspect
/**
 * A union of all supported metadata aspects for a Dataset
 */
typeref DatasetAspect = union[
  DatasetKey,
  DatasetProperties,
  EditableDatasetProperties,
  DatasetDeprecation,
  DatasetUpstreamLineage,
  UpstreamLineage,
  InstitutionalMemory,
  Ownership,
  Status,
  SchemaMetadata,
  EditableSchemaMetadata,
  GlobalTags,
  GlossaryTerms,
  BrowsePaths,
  DataPlatformInstance,
  ViewProperties
]

namespace com.linkedin.dataset

/**
 * Properties associated with a Dataset
 */
@Aspect = {
  "name": "datasetProperties"
}
record DatasetProperties includes CustomProperties, ExternalReference {

  /**
   * Documentation of the dataset
   */
  @Searchable = {
    "fieldType": "TEXT",
    "hasValuesFieldName": "hasDescription"
  }
  description: optional string

  /**
   * The abstracted URI such as hdfs:///data/tracking/PageViewEvent, file:///dir/file_name. Uri should not include any environment specific properties. Some datasets might not have a standardized uri, which makes this field optional (i.e. kafka topic).
   */
  uri: optional Uri

  /**
   * [Legacy] Unstructured tags for the dataset. Structured tags can be applied via the `GlobalTags` aspect.
   */
  tags: array[string] = [ ]
}

YAML配置模型

YAML models 配置模型:Entity Registry 基于一个叫YAML配置文件进行定义,在启动时提供给DataHub’s Metadata Service
- entity-registry.yml文件通过引用实体和方面的名称来声明它们。
- 在引导(boot)时,DataHub验证entity-registry.yml文件的结构,并确保它能找到与配置提供的每个方面名相关联的PDL模式(通过@Aspect注释)。

定义参见如下:
参见: v0.8.24 entity-registry.yml最新版 entity-registry.yml

entities:
  - name: dataset
    doc: Datasets represent logical or physical data assets stored or represented in various data platforms. Tables, Views, Streams are all instances of datasets.
    keyAspect: datasetKey
    aspects:
      - viewProperties
      - subTypes
      - datasetProfile
      - datasetUsageStatistics
      - operation
      - schemaMetadata
      - status
  - name: dataHubPolicy
    doc: DataHub Policies represent access policies granted to users or groups on metadata operations like edit, view etc.
    keyAspect: dataHubPolicyKey
    aspects:
      - dataHubPolicyInfo
  - name: dataJob
    keyAspect: dataJobKey
    aspects:
      - datahubIngestionRunSummary
      - datahubIngestionCheckpoint
  - name: corpuser
    doc: CorpUser represents an identity of a person (or an account) in the enterprise.
    keyAspect: corpUserKey
    aspects:
      - corpUserInfo
      - corpUserEditableInfo
      - corpUserStatus

探索DataHub的元数据模型

要探索研究当前的DataHub元数据模型,可以查看下面这个high-level图,它显示了不同的实体以及它们之间的关系的边。
在这里插入图片描述
针对DataHub元数据模型中最流行的实体,可以参考以下链接查看:

在元数据摄取期间,这些实体使用元数据事件表示。

参考

How does DataHub model metadata?

标签:--,实体,Entity,DataHub,Dataset,数据,metadata
来源: https://blog.csdn.net/penriver/article/details/122764944