

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 搭配 Amazon Redshift 使用 Apache Iceberg 資料表
<a name="querying-iceberg"></a>

**注意**  
 若要在搭配 Amazon Redshift 使用 Apache Iceberg 資料表時獲得最佳效能，您必須使用 AWS Glue產生資料表的欄統計資料。如需詳細資訊，請參閱《AWS Glue 開發人員指南》**中的[產生 Iceberg 資料表的欄統計資料](https://docs.aws.amazon.com/glue/latest/dg/iceberg-generate-column-stats.html)。

本主題說明如何搭配 Redshift Spectrum 或 Redshift Serverless 使用 Apache Iceberg 格式的資料表。Apache Iceberg 是適用於大型分析資料表的高效能格式。

您可以使用 Redshift Spectrum 或 Redshift Serverless 查詢 AWS Glue Data Catalog中編目的 Apache Iceberg 資料表。Apache Iceberg 是一種用於資料湖的開放原始碼資料表格式。如需詳細資訊，請參閱 Apache Iceberg 文件中的 [Apache Iceberg](https://iceberg.apache.org/)。

Amazon Redshift 為查詢 Apache Iceberg 資料表提供交易一致性。您可以在使用 Amazon Redshift 執行查詢時，使用符合 ACID (原子性、一致性、隔離、耐久性) 的服務 (例如 Amazon Athena 和 Amazon EMR) 來操控資料表中的資料。Amazon Redshift 可以使用 Apache Iceberg 中繼資料中儲存的表格統計資料來最佳化查詢計劃並減少查詢處理期間的檔案掃描。使用 Amazon Redshift SQL，您可以將 Redshift 資料表與資料湖資料表結合在一起。

若要開始將 Iceberg 資料表與 Amazon Redshift 搭配使用：

1. 使用 Amazon Athena 或 Amazon EMR 等相容服務，在 AWS Glue Data Catalog 資料庫上建立 Apache Iceberg 資料表。若要使用 Athena 建立 Iceberg 資料表，請參閱《Amazon Athena 使用者指南》**中的[使用 Apache Iceberg 資料表](https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg.html)。

1. 使用可存取資料湖的關聯 IAM 角色建立 Amazon Redshift 叢集或 Redshift Serverless 工作群組。如需如何建立叢集或工作群組的相關資訊，請參閱《Amazon Redshift 入門指南》**中的[開始使用 Amazon Redshift 佈建資料倉儲](https://docs.aws.amazon.com/redshift/latest/gsg/new-user.html)和[開始使用 Redshift Serverless 資料倉儲](https://docs.aws.amazon.com/redshift/latest/gsg/new-user-serverless.html)。

1. 使用查詢編輯器 v2 或第三方 SQL 用戶端連線到您的叢集或工作群組。如需如何使用查詢編輯器 v2 連線的相關資訊，請參閱《Amazon Redshift 管理指南》**中的[使用 SQL 用戶端工具連線至 Amazon Redshift 資料倉儲](https://docs.aws.amazon.com/redshift/latest/mgmt/connecting-to-cluster.html)。

1. 在 Amazon Redshift 資料庫中為包含 Iceberg 資料表的特定資料目錄資料庫建立外部結構描述。如需建立外部結構描述的相關資訊，請參閱[Amazon Redshift Spectrum 中的外部結構描述](c-spectrum-external-schemas.md)。

1. 執行 SQL 查詢以存取您建立的外部結構描述中的 Iceberg 資料表。

## 將 Apache Iceberg 資料表與 Amazon Redshift 搭配使用時的注意事項
<a name="querying-iceberg-considerations"></a>

將 Amazon Redshift 與 Iceberg 資料表結合使用時，請考慮以下事項：
+ **Iceberg 版本支援** - Amazon Redshift 支援對以下版本的 Iceberg 資料表執行查詢：
  + 版本 1 定義如何使用不可變資料檔案管理大型分析表。
  + 版本 2 增加支援資料列層級更新和刪除的功能，同時保持現有資料檔案不變，並使用刪除檔案來處理資料表資料變更。

   有關版本 1 和版本 2 資料表之間的區別，請參閱 Apache Iceberg 文件中的[格式版本變更](https://iceberg.apache.org/spec/#appendix-e-format-version-changes)。
+ **新增分割區** - 您不需要為 Apache Iceberg 資料表手動新增分割區。Amazon Redshift 會自動偵測 Apache Iceberg 資料表中的新分割區，而且不需要手動操作即可更新資料表定義中的分割區。分割區規格中的任何變更也會自動套用至您的查詢，而無需任何使用者介入。
+ **將 Iceberg 資料擷取至 Amazon Redshift** - 您可以使用 INSERT INTO 或 CREATE TABLE AS 命令，將資料從 Iceberg 資料表匯入本機 Amazon Redshift 資料表。您目前無法使用 COPY 命令將 Apache Iceberg 資料表的內容擷取至本機 Amazon Redshift 資料表。
+ **具體化視觀表** - 您可以在 Apache Iceberg 資料表上建立具體化視觀表，就像 Amazon Redshift 中的任何其他外部資料表一樣。其他資料湖資料表格式的考量相同，也適用於 Apache Iceberg 資料表。資料湖資料表上目前不支援自動查詢重寫和自動具體化視觀表。
+ **AWS Lake Formation 精細存取控制** – Amazon Redshift 支援 Apache Iceberg 資料表上的 AWS Lake Formation 精細存取控制。
+ **使用者定義的資料處理參數** - Amazon Redshift 支援 Apache Iceberg 資料表上的使用者定義資料處理參數。您可以在現有檔案上使用使用者定義的資料處理參數來自訂外部資料表中查詢的資料，以避免掃描錯誤。這些參數提供處理資料表結構描述與檔案實際資料之間不相符的功能。您也可以在 Apache Iceberg 資料表上使用使用者定義的資料處理參數。
+ **時間歷程查詢** - Apache Iceberg 資料表目前不支援時間歷程查詢。
+ **定價** - 當您從叢集存取 Iceberg 資料表時，您需要支付 Redshift Spectrum 定價的費用。當您從工作群組存取 Iceberg 資料表時，您需要支付 Redshift Serverless 定價的費用。如需 Redshift Spectrum 和 Redshift Serverless 定價的相關資訊，請參閱 [Amazon Redshift 定價](https://aws.amazon.com/redshift/pricing/)。
+ **中繼資料快取** - 中繼資料快取會根據 [Iceberg 規格](https://iceberg.apache.org/spec/#file-system-operations)，假設中繼資料檔案不可變。中繼資料檔案不可變性是 Amazon Redshift 中資料完整性的需求。
+ **聯合身分** – 寫入 Apache Iceberg 資料表時不支援聯合身分。這包括在建立外部結構描述時使用 IAM\$1ROLE 參數的 SESSION 關鍵字。如需 IAM\$1ROLE 參數的詳細資訊，請參閱 [CREATE EXTERNAL SCHEMA](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html)。