Lakehouse 執行階段目錄可讓您在無邊界 Lakehouse 目錄端點中建立命名空間,以便分組及整理相關資料表。
建立命名空間時,您可以選擇將其與自訂 Cloud Storage bucket 或路徑建立關聯,或沿用目錄的預設儲存位置。
事前準備
- 請參閱「關於 Lakehouse 執行階段目錄」,瞭解 Lakehouse 執行階段目錄的運作方式和服務限制。
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
Verify that billing is enabled for your Google Cloud project.
Enable the BigLake API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the serviceusage.services.enable permission. If you
created the project, then you likely already have this permission through the
Owner role (roles/owner). Otherwise, you can get this permission through the
Service Usage Admin role (roles/serviceusage.serviceUsageAdmin).
Learn how to grant roles.
必要的角色
如要取得建立命名空間所需的權限,請要求管理員授予您專案的下列 IAM 角色:
-
全部:
- BigLake 管理員 (
roles/biglake.admin) - 儲存空間管理員 (
roles/storage.admin)
- BigLake 管理員 (
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
建立命名空間
在目錄中建立命名空間。
注意事項
建立命名空間時,您可以選擇指定要與命名空間建立關聯的 Cloud Storage bucket 或路徑:
- 多 bucket 目錄 (建議):只要自訂位置位於目錄允許的位置 (
default_location或restricted_locations),即可設定任何自訂位置。如未指定位置,系統會在目錄的預設位置 (例如gs://{default_location}/{namespace_name}) 建立命名空間。 單一 bucket 目錄:命名空間位置會自動沿用目錄的單一 bucket。
控制台
前往 Google Cloud 控制台的「Lakehouse」Lakehouse頁面。
選取現有目錄,如果沒有,請建立目錄。
在開啟的「Catalog details」(目錄詳細資料) 頁面中,按一下「Create namespace」(建立命名空間)。
在「Namespace details」(命名空間詳細資料) 部分,進行下列設定:
- 在「Namespace name」(命名空間名稱) 欄位中,輸入命名空間的專屬名稱。
- 選用:在「Location」(位置) 欄位中,輸入或瀏覽要與命名空間建立關聯的 Cloud Storage bucket 或路徑。根據預設,這個欄位會填入目錄預設位置下的路徑。如果是多值區目錄,位置必須位於目錄允許的倉儲位置。如果是單一 bucket 目錄,位置會自動沿用目錄的 bucket。
- 選用:在「Owner」(擁有者) 欄位中,輸入或更新命名空間擁有者。根據預設,這個欄位會填入您的使用者名稱。
選用:如要將自訂中繼資料屬性新增至命名空間,請在「Properties」(屬性) 專區中,按一下「Add property」(新增屬性)。在「Key」(鍵) 和「Value」(值) 欄位中,輸入鍵和值。
點選「建立」。命名空間建立後,會顯示在「Catalog details」(目錄詳細資料) 頁面的「Namespaces」(命名空間) 表格中。
gcloud
在多 bucket 目錄中建立命名空間 (建議做法)
如要在多 bucket 目錄中建立命名空間 (可選擇指定自訂位置),請執行 gcloud biglake iceberg namespaces create 指令並加上 --properties 旗標:
gcloud biglake iceberg namespaces create NAMESPACE_NAME \ --project="PROJECT_ID" \ --catalog="CATALOG_ID" \ [--properties="location=LOCATION"]
更改下列內容:
NAMESPACE_NAME:命名空間的名稱。PROJECT_ID:您的 Google Cloud 專案 ID。CATALOG_ID:目錄 ID。LOCATION:(選用) 與命名空間建立關聯的自訂 Cloud Storage bucket 或路徑 (例如gs://my-bucket/my-path)。
在單一 bucket 目錄中建立命名空間
如要在單一 bucket 目錄中建立命名空間,請省略 --properties 旗標。命名空間位置會自動沿用目錄的單一 bucket。
gcloud biglake iceberg namespaces create NAMESPACE_NAME \ --project="PROJECT_ID" \ --catalog="CATALOG_ID"
REST
如要使用 REST API 建立命名空間,請將 POST 要求傳送至 CreateIcebergNamespace 端點:
POST /iceberg/v1/restcatalog/v1/projects/PROJECT_ID/catalogs/CATALOG_ID/namespaces
要求主體必須包含 Iceberg CreateNamespaceRequest JSON 酬載,用於定義命名空間 ID 和屬性:
{
"namespace": [
"NAMESPACE_NAME"
],
"properties": {
"location": "LOCATION"
}
}
更改下列內容:
PROJECT_ID:您的 Google Cloud 專案 ID。CATALOG_ID:目錄 ID。NAMESPACE_NAME:命名空間的名稱。LOCATION:(選用) 要與命名空間建立關聯的自訂 Cloud Storage bucket 或路徑 (例如gs://my-bucket/my-path)。
後續步驟
- 瞭解如何管理命名空間 ACL。