重要
Microsoft Purview データ ガバナンス機能のみの廃止
Microsoft Purview 統合カタログと従来の Microsoft Purview データ ガバナンス機能 (旧称 Azure Purview) は廃止されます。 Microsoft Purview 全体は廃止されません。 Microsoft Purview のデータ セキュリティとコンプライアンス機能は、この発表の影響を受けず、Microsoft は引き続き投資します。
Microsoft は、Microsoft Fabric のデータ ガバナンス 機能を統合しています。 新しい Microsoft Purview データ ガバナンス アカウントは作成できなくなり、既存のデータ ガバナンス機能は 2027 年 11 月 12 日までメンテナンス モードのままになります。
廃止のタイムライン、移行ガイダンス、推奨される次の手順については、 Microsoft Purview データ ガバナンスの廃止のお知らせを参照してください。
このチュートリアルでは、Microsoft Purview REST API を使用して次のことを行う方法について説明します。
- データ資産間の資産と系列関係を作成します。
- クエリ系列リレーションシップ/パス。
この記事で参照されている API:
前提条件
これらの API を使用するには、 データ キュレーター ロールとデータ閲覧者ロールが必要です。 アクセス トークンを取得する方法の詳細については、 このチュートリアル を確認してください。
概念
Asset
Microsoft Purview には、DataSet と Process の 2 種類の基本アセットがあります。
- Azure SQL Table、Oracle Tableなどのデータを含むDataSetアセットは、DataSetから継承する必要があります。
- データ パイプライン、クエリ、関数などのデータを処理するプロセス資産は、プロセスから継承する必要があります。
ア セットとタイプ を参照して、DataSets とプロセスのタイプ定義を理解します。
関係と系列
Microsoft Purview には、系列のリレーションシップには次の 3 種類があります。
- dataset_process_inputs: DataSetをプロセスに接続します。これは、DataSetがプロセスの入力であることを意味します。
- process_dataset_outputs: プロセスをDataSetに接続します。これは、プロセスがDataSetを生成することを意味します。
- direct_lineage_dataset_dataset: DataSet1 を DataSet2 に接続します。つまり、DataSet1 が DataSet2 のアップストリームであることを意味しますが、どちらのプロセスがどちらの間にあるかは正確にはわかりません
例 1:以下は、2 つの DataSet、1 つのプロセス、2 つの系列関係を持つ系列の例です。
データセット ---> dataset_process_inputs ---> プロセス ---> process_dataset_outputs ---> データセット
例2:2つのDataSetと1つの系列関係を持つ系列の別の例:
データセット ---> direct_lineage_dataset_dataset ---> データセット
データ資産間の資産と系列関係の作成
次のセクションでは、DataSet の例の型として hive_table を、Processの型の例として hive_query_process をとっていきます。 この 2 つのタイプのアセットを作成し、それらの間の系列を作成します。 DataSetまたはProcessから継承する他のタイプを使用して、系列を作成できます。
例 1
API を使用したアセットの作成
系列を作成する資産がまだ Microsoft Purview で作成されていない場合は、次の API を呼び出して作成できます。
API: アセットの一括作成
タスク: 2 つのhive_tables (table1 と table2) を、それぞれ 2 つのhive_columns (column1 と column2) を持つデータセットとして作成します。
POST {endpoint}/datamap/api/atlas/v2/entity/bulk
本文で:
{
"entities": [
{
"typeName": "hive_table",
"attributes": {
"qualifiedName": "test_lineage.table1",
"name": "table1"
},
"relationshipAttributes": {
"columns": [
{
"guid": "-11",
"typeName": "hive_column"
},{
"guid": "-12",
"typeName": "hive_column"
}
]
},
"guid": "-1"
},
{
"typeName": "hive_column",
"attributes": {
"qualifiedName": "test_lineage.table1#column1",
"name": "column1",
"type": "int"
},
"guid": "-11",
"relationshipAttributes": {
"table": {
"guid": "-1",
"typeName": "hive_table"
}
}
},
{
"typeName": "hive_column",
"attributes": {
"qualifiedName": "test_lineage.table1#column2",
"name": "column2",
"type": "int"
},
"guid": "-12",
"relationshipAttributes": {
"table": {
"guid": "-1",
"typeName": "hive_table"
}
}
},
{
"typeName": "hive_table",
"attributes": {
"qualifiedName": "test_lineage.table2",
"name": "table2"
},
"relationshipAttributes": {
"columns": [
{
"guid": "-21",
"typeName": "hive_column"
},{
"guid": "-22",
"typeName": "hive_column"
}
]
},
"guid": "-2"
},
{
"typeName": "hive_column",
"attributes": {
"qualifiedName": "test_lineage.table2#column1",
"name": "column1",
"type": "int"
},
"guid": "-21",
"relationshipAttributes": {
"table": {
"guid": "-2",
"typeName": "hive_table"
}
}
},
{
"typeName": "hive_column",
"attributes": {
"qualifiedName": "test_lineage.table2#column2",
"name": "column2",
"type": "int"
},
"guid": "-22",
"relationshipAttributes": {
"table": {
"guid": "-2",
"typeName": "hive_table"
}
}
}
]
}
タスク: プロセス資産 'hive_view_query' を作成する
POST {endpoint}/datamap/api/atlas/v2/entity/bulk
本文で:
{
"entities": [
{
"typeName": "hive_view_query",
"attributes": {
"qualifiedName": "test_lineage.HiveQuery1",
"name": "HiveQuery1",
"columnMapping": "[{\"DatasetMapping\":{\"Source\":\"test_lineage.table1\",\"Sink\":\"test_lineage.table2\"},\"ColumnMapping\":[{\"Source\":\"column1\",\"Sink\":\"column1\"},{\"Source\":\"column2\",\"Sink\":\"column2\"}]}]"
},
"guid": "-1"
}
]
}
上記の API 呼び出しにより、2 つの hive_tables(データセット) と 1 つの hive_view_query(プロセス) が作成されます。
データセットとプロセス間の系列関係の作成
API: リレーションシップの作成
タスク: table1 から系列を作成する -> HiveQuery1 (つまり、データセット -> プロセス)
POST {endpoint}/datamap/api/atlas/v2/relationship
本文で:
{
"typeName": "dataset_process_inputs",
"guid": "-1",
"end1": {
"typeName": "hive_table",
"uniqueAttributes": {
"qualifiedName": "test_lineage.table1"
}
},
"end2": {
"typeName": "Process",
"uniqueAttributes": {
"qualifiedName": "test_lineage.HiveQuery1"
}
}
}
タスク: HiveQuery1 -> table2 から系列を作成する (つまり、プロセス -> データセット)
POST {endpoint}/datamap/api/atlas/v2/relationship
本文で:
{
"typeName": "process_dataset_outputs",
"guid": "-2",
"end1": {
"typeName": "Process",
"uniqueAttributes": {
"qualifiedName": "test_lineage.HiveQuery1"
}
},
"end2": {
"typeName": "hive_table",
"uniqueAttributes": {
"qualifiedName": "test_lineage.table2"
}
}
}
系列の表示
資産と系列の関係が作成されたら、Microsoft Purview で系列グラフを確認できます。
例 2
2 つの列を含むハイブ テーブル table3 を作成します
API: アセットの一括作成
タスク: 2 つのhive_columns、column1、column2 を持つ table3 を作成します
POST {endpoint}/datamap/api/atlas/v2/entity/bulk
本文で:
{
"entities": [
{
"typeName": "hive_table",
"attributes": {
"qualifiedName": "test_lineage.table3",
"name": "table3"
},
"relationshipAttributes": {
"columns": [
{
"guid": "-31",
"typeName": "hive_column"
},{
"guid": "-32",
"typeName": "hive_column"
}
]
},
"guid": "-3"
},
{
"typeName": "hive_column",
"attributes": {
"qualifiedName": "test_lineage.table3#column1",
"name": "column1",
"type": "int"
},
"guid": "-31",
"relationshipAttributes": {
"table": {
"guid": "-3",
"typeName": "hive_table"
}
}
},
{
"typeName": "hive_column",
"attributes": {
"qualifiedName": "test_lineage.table3#column2",
"name": "column2",
"type": "int"
},
"guid": "-32",
"relationshipAttributes": {
"table": {
"guid": "-3",
"typeName": "hive_table"
}
}
}
]
}
列マッピングを使用して表 2 と表 3 の間に直接系列を作成します
API: リレーションシップの作成
タスク: 列マッピングを使用して table2 -> table3 (つまり、データセット -> データセット) から系列を作成します
POST {endpoint}/datamap/api/atlas/v2/relationship
本文で:
{
"typeName": "direct_lineage_dataset_dataset",
"guid": "-1",
"end1": {
"typeName": "hive_table",
"uniqueAttributes": {
"qualifiedName": "test_lineage.table2"
}
},
"end2": {
"typeName": " hive_table ",
"uniqueAttributes": {
"qualifiedName": "test_lineage.table3"
}
},
"attributes": {
"columnMapping": "[{\"Source\":\"column1\",\"Sink\":\"column1\"},{\"Source\":\"column2\",\"Sink\":\"column2\"}]"
}
}
系列の表示
これで、系列グラフ (上記の例 1 & 例 2 を合わせた) は次のようになります。
table2 は table3 に直接リンクされており、間に HiveQuery はありません。
クエリ系列リレーションシップ/パス
API: GUID による系列の取得
タスク: REST API を使用して table2 の系列を取得する
GET {{endpoint}}/api/atlas/v2/lineage/{{guid_of_table2}}?direction=BOTH
以下では、JSON 応答ペイロードを実行できます。
{
"baseEntityGuid": "2a12b3ff-5816-4222-833a-035bf82e06e0",
"lineageDirection": "BOTH",
"lineageDepth": 3,
"lineageWidth": -1,
"childrenCount": -1,
"guidEntityMap": {
"16b93b78-8683-4f88-9651-24c4a9d797b0": {
"typeName": "hive_table",
"attributes": {
"temporary": false,
"lastAccessTime": 0,
"createTime": 0,
"qualifiedName": "test_lineage.table3",
"name": "table3",
"retention": 0
},
"lastModifiedTS": "1",
"guid": "16b93b78-8683-4f88-9651-24c4a9d797b0",
"status": "ACTIVE",
"displayText": "table3",
"classificationNames": [],
"meaningNames": [],
"meanings": [],
"isIncomplete": false,
"labels": [],
"isIndexed": true
},
"cb22ba23-47a2-4149-ade6-e3d9642fe592": {
"typeName": "hive_table",
"attributes": {
"temporary": false,
"lastAccessTime": 0,
"createTime": 0,
"qualifiedName": "test_lineage.table1",
"name": "table1",
"retention": 0
},
"lastModifiedTS": "1",
"guid": "cb22ba23-47a2-4149-ade6-e3d9642fe592",
"status": "ACTIVE",
"displayText": "table1",
"classificationNames": [],
"meaningNames": [],
"meanings": [],
"isIncomplete": false,
"labels": [],
"isIndexed": true
},
"bbeacce6-5bde-46f7-8fe4-689cbb36ba51": {
"typeName": "hive_view_query",
"attributes": {
"qualifiedName": "test_lineage.HiveQuery1",
"name": "HiveQuery1",
"columnMapping": "[{\"DatasetMapping\":{\"Source\":\"test_lineage.table1\",\"Sink\":\"test_lineage.table2\"},\"ColumnMapping\":[{\"Source\":\"column1\",\"Sink\":\"column1\"},{\"Source\":\"column2\",\"Sink\":\"column2\"}]}]"
},
"lastModifiedTS": "1",
"guid": "bbeacce6-5bde-46f7-8fe4-689cbb36ba51",
"status": "ACTIVE",
"displayText": "HiveQuery1",
"classificationNames": [],
"meaningNames": [],
"meanings": [],
"isIncomplete": false,
"labels": [],
"isIndexed": true
},
"2a12b3ff-5816-4222-833a-035bf82e06e0": {
"typeName": "hive_table",
"attributes": {
"temporary": false,
"lastAccessTime": 0,
"createTime": 0,
"qualifiedName": "test_lineage.table2",
"name": "table2",
"retention": 0
},
"lastModifiedTS": "1",
"guid": "2a12b3ff-5816-4222-833a-035bf82e06e0",
"status": "ACTIVE",
"displayText": "table2",
"classificationNames": [],
"meaningNames": [],
"meanings": [],
"isIncomplete": false,
"labels": [],
"isIndexed": true
}
},
"includeParent": false,
"relations": [
{
"fromEntityId": "2a12b3ff-5816-4222-833a-035bf82e06e0",
"toEntityId": "16b93b78-8683-4f88-9651-24c4a9d797b0",
"relationshipId": "23df8e3e-b066-40b2-be29-9fd90693c51b",
"columnMapping": "[{\"Source\":\"column1\",\"Sink\":\"column1\"},{\"Source\":\"column2\",\"Sink\":\"column2\"}]"
},
{
"fromEntityId": "bbeacce6-5bde-46f7-8fe4-689cbb36ba51",
"toEntityId": "2a12b3ff-5816-4222-833a-035bf82e06e0",
"relationshipId": "5fe8d378-39cd-4c6b-8ced-91b0152d3014"
},
{
"fromEntityId": "cb22ba23-47a2-4149-ade6-e3d9642fe592",
"toEntityId": "bbeacce6-5bde-46f7-8fe4-689cbb36ba51",
"relationshipId": "73e084bf-98a3-45fb-a1e4-c56cc40661b8"
}
],
"parentRelations": [],
"widthCounts": {
"INPUT": {
"cb22ba23-47a2-4149-ade6-e3d9642fe592": 0,
"bbeacce6-5bde-46f7-8fe4-689cbb36ba51": 1,
"2a12b3ff-5816-4222-833a-035bf82e06e0": 1
},
"OUTPUT": {
"16b93b78-8683-4f88-9651-24c4a9d797b0": 0,
"2a12b3ff-5816-4222-833a-035bf82e06e0": 1
}
}
}
その他のリソース
型定義
すべての資産/エンティティとリレーションシップは、タイプ システムで定義されます。
すべての タイプ定義の一覧 表示 API を呼び出して、Microsoft Purview インスタンスの現在のタイプ定義を取得します。 説明されている API 呼び出しで使用する typeName がわからない場合は、タイプ定義 API を確認して適切なアセット/エンティティ型を見つけることができます。
この API の応答の例を次に示します。
上記の応答の entityDefs で、アセットの種類 (oracle_table、oracle_view など) が定義されていることがわかります。 アセットの定義(この例ではoracle_view)をさらに詳しく見ると、アセットが継承されたDataSet型であることがわかります。
同様に、以下に示すように、プロセス (Oracle_function など) が "Process" 型から継承されていることがわかります。
新しいカスタム型の作成
カスタム アセットまたはプロセスを作成する場合は、次の API を使用できます。
API: Typedef API の作成
タスク: カスタム プロセスの種類を作成する
POST {endpoint}/datamap/api/atlas/v2/types/typedefs
本文で:
{
"enumDefs": [],
"structDefs": [],
"classificationDefs": [],
"entityDefs": [
{
"name": "MyCustomServiceProcess",
"superTypes": [
"Process"
],
"typeVersion": "1.0",
"attributeDefs": []
}
],
"relationshipDefs": []
}
タスク:カスタムDataSet型を作成する
POST {endpoint}/datamap/api/atlas/v2/types/typedefs
本文で:
{
"enumDefs": [],
"structDefs": [],
"classificationDefs": [],
"entityDefs": [
{
"name": "MyCustomDataSet",
"superTypes": [
"DataSet"
],
"typeVersion": "1.0",
"attributeDefs": []
}
],
"relationshipDefs": []
}