OpenLineage 映射

Data Lineage API 可以从与 OpenLineage(一种用于沿袭收集的开放标准)集成的系统中注入沿袭信息。当您使用 ProcessOpenLineageRunEvent 方法将 OpenLineage 格式的事件发送到 Data Lineage API 时,Data Lineage API 会将 OpenLineage 消息中的属性映射到 Data Lineage API 中的相应属性。

本文档提供了这些映射的参考表。

属性映射

ProcessOpenLineageRunEvent REST API 方法会将 OpenLineage 属性映射到 Data Lineage API 属性,如下所示:

Data Lineage API 特性 OpenLineage 属性
Process.name projects/PROJECT_NUMBER/locations/LOCATION/processes/HASH_OF_NAMESPACE_AND_NAME
Process.displayName Job.namespace + ":" + Job.name
Process.attributes Job.facets(请参阅存储的数据)
Run.name projects/PROJECT_NUMBER/locations/LOCATION/processes/HASH_OF_NAMESPACE_AND_NAME/runs/HASH_OF_RUNID
Run.displayName Run.runId
Run.attributes Run.facets(请参阅存储的数据)
Run.startTime eventTime
Run.endTime eventTime
Run.state eventType
LineageEvent.name projects/PROJECT_NUMBER/locations/LOCATION/processes/HASH_OF_NAMESPACE_AND_NAME/runs/HASH_OF_RUNID/lineageEvents/HASH_OF_JOB_RUN_INPUT_OUTPUTS_OF_EVENT(例如,projects/11111111/locations/us/processes/1234/runs/4321/lineageEvents/111-222-333)
LineageEvent.EventLinks.source 输入(fqn 是命名空间和名称串联)
LineageEvent.EventLinks.target 输出(fqn 是命名空间和名称串联)
LineageEvent.startTime eventTime
LineageEvent.endTime eventTime
requestId 由方法用户定义

如果列级血缘由 Managed Service for Apache Spark 自动生成,则支持列级血缘,前提是它使用 outputs 对象中的 columnLineage 方面。包含此 facet 的自定义 OpenLineage 事件仅具体化表级沿袭,不会在 Google Cloud 控制台中呈现列级沿袭。以下是 Managed Service for Apache Spark 生成的 Facet 示例:

"outputs": [ {
  "namespace": "bigquery",
  "name": "project.dataset.outputtable",
  "columnLineage": {
      "_producer": "https://github.com/OpenLineage/OpenLineage/tree/1.39.0/integration/spark",
      "_schemaURL": "https://openlineage.io/spec/facets/1-2-0/ColumnLineageDatasetFacet.json#/$defs/ColumnLineageDatasetFacet",
      "fields": {
        "output_field": { // This is the name of the output field
          "inputFields": [
            {
              "namespace": "bigquery",
              "name": "project.dataset.inputtable",
              "field": "input_field", // This is the name of the input field
              "transformations": [
                {
                  "type": "DIRECT",
                  "subtype": "IDENTITY",
                  "description": "",
                  "masking": false
                }
              ]
            }
          ]
        }
      },
  }
}]

在此示例中,您将在 input_field 和 output_field 之间创建列级沿袭链接。您必须添加 transformations 字段,否则系统不会提取列级沿袭。如需详细了解此 facet 的 Open Lineage 定义,请参阅列级数据集 facet。

FQN 映射

下表提供了各种系统的 OpenLineage 命名空间和名称对示例,以及其等效的 Knowledge Catalog(原 Dataplex Universal Catalog)完全限定名称 (FQN):

系统 OpenLineage 命名空间 OpenLineage 名称 Knowledge Catalog FQN
Athena awsathena://athena.{region_name}.amazonaws.com
  • {catalog}
  • {catalog}.{database}
  • {catalog}.{database}.{table}
  • athena:{catalogId}.{region}
  • athena:{catalogId}.{region}.{databaseId}
  • athena:{catalogId}.{region}.{databaseId}.{tableId}
AWS Glue arn:aws:glue:{region}:{account id} table/{database name}/{table name} aws_glue:table:{region}.{account id}.{database name}.{table name}
Azure Cosmos DB azurecosmos://{host}/dbs/{database} colls/{table}
  • cosmos-db:{host}.{database}
  • cosmos-db:{host}.{database}.{table}
Azure Data Explorer azurekusto://{host}.kusto.windows.net {database}/{table}
  • kusto:{host}.{region}.{database}
  • kusto:{host}.{region}.{database}.{table}
Azure Synapse sqlserver://{host}:{port}
  • {database}
  • {database}.{schema}
  • {database}.{schema}.{table}
不支持
BigQuery bigquery
  • {project id}.{dataset name}
  • {project id}.{dataset name}.{table name}
  • bigquery:{projectId}.{datasetId}
  • bigquery:{projectId}.{datasetId}.{assetId}
Cassandra cassandra://{host}:{port}
  • {keyspace}
  • {keyspace}.{table}
  • cassandra:{hostWithPort}.{keyspaceId}
  • cassandra:{hostWithPort}.{keyspaceId}.{tableId}
MySQL mysql://{host}:{port}
  • {database}
  • {database}.{table}
  • mysql:{hostWithPort}.{databaseId}
  • mysql:{hostWithPort}.{databaseId}.{tableId}
CrateDB crate://{host}:{port} {database}.{schema}.{table} 不支持
DB2 db2://{host}:{port}
  • {database}
  • {database}.{schema}
  • {database}.{schema}.{table}
  • db2:{dns}.{databaseId}
  • db2:{dns}.{databaseId}.{schemaId}
  • db2:{dns}.{databaseId}.{schemaId}.{tableId}
Hive hive://{host}:{port} {database}.{table} 不支持
MSSQL mssql://{host}:{port} {database}.{schema}.{table} 不支持
OceanBase oceanbase://{host}:{port} {database}.{table} 不支持
Oracle oracle://{host}:{port} {serviceName}.{schema}.{table} or {sid}.{schema}.{table}
  • oracle:{hostWithPort}.{databaseId}
  • oracle:{hostWithPort}.{databaseId}.{schemaId}
  • oracle:{hostWithPort}.{databaseId}.{schemaId}.{tableId}
Postgres postgres://{host}:{port}
  • {database}
  • {database}.{schema}
  • {database}.{schema}.{table}
  • postgresql:{hostWithPort}.{databaseId}
  • postgresql:{hostWithPort}.{databaseId}.{schemaId}
  • postgresql:{hostWithPort}.{databaseId}.{schemaId}.{tableId}
TeraData teradata://{host}:{port} {database}.{table} 不支持
Redshift redshift://{cluster_identifier}.{region_name}:{port}
  • {database}
  • {database}.{schema}
  • {database}.{schema}.{table}
  • redshift:{clusterId}.{region}.{port}.{databaseId}
  • redshift:{clusterId}.{region}.{port}.{databaseId}.{schemaId}
  • redshift:{clusterId}.{region}.{port}.{databaseId}.{schemaId}.{tableId}
Snowflake snowflake://{organization name}-{account name} or snowflake://{account-locator}(.{compliance})(.{cloud_region_id})(.{cloud})
  • {database}
  • {database}.{schema}
  • {database}.{schema}.{table}
  • snowflake:{accountName}.{databaseId}
  • snowflake:{accountName}.{databaseId}.{schemaId}
  • snowflake:{accountName}.{databaseId}.{schemaId}.{tableId}
Spanner spanner://{projectId}:{instanceId} {database}.{schema}.{table} Knowledge Catalog 支持,但数据沿袭不支持
Trino trino://{host}:{port}
  • {catalog}
  • {catalog}.{schema}
  • {catalog}.{schema}.{table}
  • trino:{hostWithPort}.{catalogId}
  • trino:{hostWithPort}.{catalogId}.{schemaId}
  • trino:{hostWithPort}.{catalogId}.{schemaId}.{tableId}
ABFSS (Azure Data Lake Gen2) abfss://{container name}@{service name}.dfs.core.windows.net {path}
  • abs:{serviceName}.{containerName}
  • abs:{serviceName}.{containerName}.{path}
DBFS(Databricks 文件系统) dbfs://{workspace name} {path}
  • dbfs:{workspace}
  • dbfs:{workspace}.{path}
Cloud Storage gs://{bucket name} {object key}
  • gcs:{bucketName}
  • gcs:{bucketName}.{virtualPath}
HDFS hdfs://{namenode host}:{namenode port} {path}
  • hdfs:{namenodeHostWithPort}
  • hdfs:{namenodeHostWithPort}.{path}
Kafka kafka://{bootstrap server host}:{port} {topic} kafka:{serverHostWithPort}.{topicId}
本地文件系统 file {path} filesystem:localhost.{path}
远程文件系统 file://{host} {path} filesystem:{hostWithPort}.{path}
S3 s3://{bucket name} {object key}
  • s3:{bucketName}
  • s3:{bucketName}.{objectKey}

命名空间前缀 s3a 和 s3n 也可接受,并会转换为 s3
WASBS (Azure Blob Storage) wasbs://{container name}@{service name}.dfs.core.windows.net {object key}
  • abs:{serviceName}.{containerName}
  • abs:{serviceName}.{containerName}.{objectKey}
Pub/Sub 主题 pubsub topic:{projectId}:{topicId} pubsub:topic:{projectId}.{topicId}
Pub/Sub 订阅 pubsub subscription:{projectId}:{subscriptionId} pubsub:subscription:{projectId}.{subscriptionId}

其他可接受的格式

虽然 OpenLineage 未为以下系统定义标准 namespace/name 对,但 Data Lineage API 接受这些系统的沿袭事件,前提是这些事件的格式符合下表中的说明。在 OpenLineage 消息中引用且命名空间为 custom 的资源会被解读为自定义的完全限定名称。

系统 OpenLineage 命名空间 OpenLineage 名称 Knowledge Catalog FQN
自定义 FQN custom {some reference} custom:{someReference}
Dataproc Metastore dataproc_metastore
  • dataproc_metastore:{projectId}.{location}.{instanceId}
  • dataproc_metastore:{projectId}.{location}.{instanceId}.{databaseId}
  • dataproc_metastore:{projectId}.{location}.{instanceId}.{databaseId}.{tableId}
  • dataproc_metastore:{projectId}.{location}.{instanceId}
  • dataproc_metastore:{projectId}.{location}.{instanceId}.{databaseId}
  • dataproc_metastore:{projectId}.{location}.{instanceId}.{databaseId}.{tableId}

Lakehouse 目录(基于分面的映射)

与上表中的系统不同,Lakehouse 目录的表级和列级标识符并非通过串联 OpenLineage 数据集 namespace 和 name 派生。相反,Data Lineage API 会使用数据集 facets.catalog 和 facets.symlinks 字段解析 Apache Iceberg 和 Hive 目录表。

以下配置决定了 API 构建的 FQN 格式:

  • Lakehouse Iceberg REST 目录:
    • 触发逻辑:facets.catalog.type为 "rest" 且 facets.catalog.metadataUri 包含 biglake.googleapis.com。
    • FQN 构造:使用 catalogProperties.gcp_project_id 或 {projectId} 的 bl:// 仓库 URI 中的项目、仓库 URI 中的 catalogId 以及 TABLE 符号链接中的 {namespaceId}.{tableId} 构建 biglake:table:{projectId}.{catalogId}.{namespaceId}.{tableId}。
  • Lakehouse Hive 目录:
    • 触发逻辑:facets.catalog.type为 "gcp_lakehouse",facets.catalog.framework为 "hive"。
    • FQN 构造:使用 {projectId} 的 catalogProperties.gcp_project_id、{catalogId} 的 facets.catalog.name 以及 TABLE 符号链接中的两段式 name 构建 biglake:table:{projectId}.{catalogId}.{namespaceId}.{tableId}。
  • Lakehouse 运行时目录 (bigquerymetastore):
    • 触发逻辑:facets.catalog.type为 "bigquerymetastore"。
    • FQN 构建:使用 {projectId} 的 catalogProperties.gcp_project_id 以及 TABLE 符号链接中的 {datasetId}.{tableId} 构建 bigquery:{projectId}.{datasetId}.{tableId}。

以下示例展示了用于将 Iceberg REST 目录表映射到 biglake:table:my-project.my_catalog.my_namespace.my_table 的数据集 facet:

{
  "namespace": "bl://projects",
  "name": "/my-project/catalogs/my_catalog/my_namespace/my_table",
  "facets": {
    "catalog": {
      "framework": "iceberg",
      "type": "rest",
      "name": "my_catalog",
      "metadataUri": "https://biglake.googleapis.com/iceberg/v1/restcatalog",
      "warehouseUri": "bl://projects/my-project/catalogs/my_catalog",
      "catalogProperties": {
        "gcp_project_id": "my-project"
      }
    },
    "symlinks": {
      "identifiers": [
        {
          "namespace": "https://biglake.googleapis.com/iceberg/v1/restcatalog",
          "name": "my_namespace.my_table",
          "type": "TABLE"
        }
      ]
    }
  }
}

后续步骤