Unity Catalog REST API 與 Iceberg Catalog REST API
元資料服務實作了 Iceberg REST Catalog 和 Unity Catalog Open API 規格中選定的 API。 您可以利用標準 REST 用戶端中的這些 API。 使用 REST 用戶端的好處是無需引擎即可直接與元儲存互動。
Unity 目錄 REST API
以下是包含的 API:
型錄
- 郵寄/目錄
- 取得/目錄
- GET /目錄/ {name}
- 補丁/目錄/ {name}
- 刪除/目錄/ {name}
綱目
- POST /schemas
- 取得/模式
- GET /schemas/ {full_name}
- 補丁/模式/ {full_name}
- 刪除/模式/ {full_name}
Tables
- 發布/表
- 取得/表
- GET /表/ {full_name}
- 刪除/表/ {full_name}
用於 GET 目錄的範例 Unity API
curl -k -X GET "https://80e7cce9-c14f-4aa8-8a3b-c52adc25efac.cdc406pd09pasng7elgg.lakehouse.dev.appdomain.cloud:32230/api/2.1/unity-catalog/catalogs" --header "Authorization: Bearer $token" --header 'Content-Type: application/json'
{
"catalogs": [
{
"name": "ad_catalog",
"comment": "",
"properties": {
"catalogType": "delta",
"storageName": "func-test-bucket"
},
"created_at": 1733724384000,
"updated_at": 0,
"id": "3186f83a-8879-46c4-b48e-125741c34e88",
"owner": "anurag",
"created_by": "anurag",
"updated_by": null
},
{
"name": "testth",
"comment": "",
"properties": {
"catalogType": "iceberg",
"storageName": "mdshms"
},
"created_at": 1733724482000,
"updated_at": 0,
"id": "9ce30ab7-1321-4189-bb10-765093d1932c",
"owner": "antony",
"created_by": "antony",
"updated_by": null
}
],
"next-page-token": null
}
用於目錄 GET 架構的範例 Unity API
curl -k -X GET "https://80e7cce9-c14f-4aa8-8a3b-c52adc25efac.cdc406pd09pasng7elgg.lakehouse.dev.appdomain.cloud:32230/api/2.1/unity-catalog/schemas?catalog_name=mrmadira_hive_catalog" --header "Authorization: Bearer $token" --header 'Content-Type: application/json'
{
"schemas": [
{
"name": "dec92024",
"catalog_name": "mrmadira_hive_catalog",
"comment": null,
"properties": {
"locationUri": "s3a://testbucket/dec92024"
},
"full_name": "mrmadira_hive_catalog.dec92024",
"created_at": 0,
"updated_at": 0,
"schema_id": "135"
}
]
}
行為和限制
由於不能修改架構的限制,一些必填欄位必須包含在 properties
Unity REST 規範的欄位。
為了建立目錄,locationUri
、儲存桶名稱(在 watsonx.data 中註冊),以及 catalogType
字段是強制性的,必須在 properties
場地:
"properties": {
"locationUri": "s3a://func-test-bucket/unity_schema",
"bucket": "func-test-bucket",
"catalogType": "ICEBERG"
}
對於建立模式,locationUri 是必填字段,並且必須包含在 properties
場地:
"properties": {
"locationUri": "s3a://func-test-bucket/unity_schema"
}
對於建立表,Unity 規範中有一些附加欄位不可用。 元資料服務會忽略為這些欄位提供的任何信息,並且不會儲存在資料庫中:
"columns": [
{
"type_json": "string",
"type_name": "string",
"type_precision": 0,
"type_scale": 0,
"type_interval_type": "string",
"position": 0,
"nullable": true,
"partition_index": 0
}
]
如果在請求物件的屬性中傳遞額外的值,由於遵守目前的 HMS 架構,它們不會儲存在任何表中。 您可以在 properties
如果需要的話,可以在未來的領域。
有關更多信息,請參閱 API 文件。
冰山目錄 REST API
以下是包含的 API:
名稱空間
- 列出命名空間
- 建立名稱空間
- 載入命名空間的元資料屬性
- 檢查命名空間是否存在
- 刪除命名空間
冰山表相關
- 在給定的命名空間中建立表
- 使用metadata_location註冊表
- 載入表格
- 檢查表是否存在
- 重新命名表
- 在原子事務中提交對多個表的更新
- 提交對錶的更新
- 捨棄表格
視圖
- 列出所有視圖標識符
- 載入視圖
- 檢查視圖是否存在
- 重新命名視圖
- 捨棄視圖
配置
- 配置端點以將目錄配置為前綴
Iceberg API 範例
取得目錄的命名空間
curl -k --request GET --url 'https://80e7cce9-c14f-4aa8-8a3b-c52adc25efac.cdc406pd09pasng7elgg.lakehouse.dev.appdomain.cloud:32230/mds/iceberg/v1/hemant_test/namespaces' --header 'Accept: application/json' --header "Authorization: Bearer $token" --header 'Content-Type: application/json' | jq
{
"namespaces": [
[
"hemant_test"
],
[
"order_schema_ad"
],
[
"schema1150850f-ece4-4c27-8794-e05b984adff5"
]
],
"next-page-token": null
}
取得模式的表
curl -k --request GET --url 'https://80e7cce9-c14f-4aa8-8a3b-c52adc25efac.cdc406pd09pasng7elgg.lakehouse.dev.appdomain.cloud:32230/mds/iceberg/v1/hemant_test/namespaces/schema_cpd' --header 'Accept: application/json' --header "Authorization: Bearer $token" --header 'Content-Type: application/json' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 74 0 74 0 0 52 0 --:--:-- 0:00:01 --:--:-- 52
{
"namespace": [
"schema_cpd"
],
"properties": {
"owner": "hemant"
}
}
行為和限制
由於不修改架構的限制,不支援以下功能:
- 多級命名空間創建
- 由於 Hive 是DBS表中所有資料庫或命名空間的目錄,因此即使存在於Iceberg以外的目錄中,也不支援建立命名空間。
- 如果列出架構,則僅傳回具有指定前綴的目前目錄的命名空間。 但是,如果您嘗試建立另一個目錄中存在的命名空間,則會出現
Namespace Already Exists
傳回異常。 - 列出表格時,僅傳回 Iceberg 表。 如果您嘗試建立的表格的名稱與相同資料庫或命名空間中的 Hive 或 Delta 表存在,則不允許建立同名的 Iceberg 表。
- 不支援 X-Iceberg-Access-Delegation。
- 僅作為虛擬添加的指標端點。
- Presto 由於編碼不相容,無法查詢使用 Iceberg REST 目錄 API 建立的檢視。 這種不相容性同樣會影響從 Spark 建立的檢視,而 Presto 也無法查詢這些檢視。 然而,Spark 可以毫無問題地查詢透過 REST 目錄 API 建立的檢視。
有關更多信息,請參閱 API 文件。
常見限制:目錄和資料表建立時不支援的屬性
由於目前的模式限制,在建立目錄和資料表時,將不會儲存下列屬性:
- 如需目錄:
- 註解
- 對於表格 (在列陣列中):
- 類型精確度
- 類型刻度
- type_interval_type
- 位置
- 可為空值
- 分區索引
- 對於表格 (在列陣列之外):
- 註解