

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

# 查詢 Apache Iceberg 資料表
<a name="querying-iceberg"></a>

您可以使用 Athena 在 Apache Iceberg 資料表上執行讀取、時間歷程、寫入和 DDL 查詢。

[Apache Iceberg](https://iceberg.apache.org/) 是開放式的資料表格式，專用於非常大型的分析資料集。Iceberg 以管理資料表的方式來管理大量的檔案集合並支援新型的分析資料湖操作，如記錄層級的插入、更新、刪除和時間歷程查詢。Iceberg 規格可讓資料表的結構描述和分割區等變化順暢無礙，並專為最佳化 Amazon S3 的使用所設計。Iceberg 也有助於在並行寫入的情況下保證資料的正確性。

如需 Apache Iceberg 的相關詳細資訊，請參閱 [https://iceberg.apache.org/](https://iceberg.apache.org/)。

## 考量和限制
<a name="querying-iceberg-considerations-and-limitations"></a>

Athena 對 Iceberg 資料表的支援有以下考量事項和限制：
+ **Iceberg 版本支援** – Athena 支援 Apache Iceberg 1.4.2 版。
+ **向 Lake Formation 註冊的資料表** – Athena 目前不支援對向 Lake Formation 註冊的 Iceberg 資料表進行 DDL 操作。
+ **針對資訊結構描述的查詢** – 查詢 Iceberg 資料表的資訊結構描述時，Athena 會使用 S3 中繼資料作為資料欄中繼資料的事實來源。這表示資料欄資訊衍生自基礎 S3 檔案，而不是目錄中繼資料。此行為不同於其他資料表格式，其中目錄中繼資料可能是資料欄資訊的主要來源。
+ ** AWS Glue 僅限目錄的資料表** – Athena 僅支援根據開放原始碼黏附 AWS Glue 目錄實作所定義的規格，針對目錄建立的 Iceberg 資料表。 [https://iceberg.apache.org/docs/latest/aws/#glue-catalog](https://iceberg.apache.org/docs/latest/aws/#glue-catalog)
+ ** AWS Glue 僅支援資料表鎖定** – 與支援外掛程式自訂鎖定的開放原始碼 Glue 目錄實作不同，Athena 僅支援 AWS Glue 樂觀鎖定。使用 Athena 修改具有任何其他鎖定實作的 Iceberg 資料表將導致潛在的資料遺失和交易中斷。
+ **支援的檔案格式** – Athena 引擎版本 3 支援下列 Iceberg 檔案格式。
  + Parquet
  + ORC
  + Avro
+ **Iceberg 受限制的中繼資料** – Lake Formation 不會評估 Iceberg 中繼資料資料表。因此，如果基本資料表上有任何 Lake Formation 資料列或儲存格篩選條件，或者您沒有檢視基本資料表中所有資料欄的許可，則 Iceberg 中繼資料資料表會受到限制。在這種情況下，當您查詢 `$partitions`、`$files`、`$manifests` 和 `$snapshots` Iceberg 中繼資料表時，它會失敗並收到 `AccessDeniedException` 錯誤。此外，中繼資料欄 `$path` 具有相同的 Lake Formation 限制，並在查詢選取時會失敗。無論 Lake Formation 篩選條件為何，都可以查詢所有其他中繼資料資料表。如需詳細資訊，請參閱[中繼資料資料表](https://trino.io/docs/current/connector/iceberg.html#metadata-tables)。
+ **Iceberg v2 資料表** – Athena 只能建立及操作 Iceberg v2 資料表。有關 v1 和 v2 資料表之間的區別，請參閱 Apache Iceberg 文件中的[格式版本變更](https://iceberg.apache.org/spec/#appendix-e-format-version-changes)。
+ **顯示不含時區的時間類型** – 以世界協調時間 (UTC) 顯示不含時區類型的時間和時間戳記。如果在時間資料欄的篩選條件表達式中未指定時區，則使用世界協調時間 (UTC)。
+ **與時間戳記相關的資料精確度** – 雖然 Iceberg 支持時間戳記資料類型的精度達到微秒，但 Athena 僅在讀取和寫入的時間戳記中支持達毫秒的精度。針對在手動壓縮操作過程中重寫的時間相關資料欄中的資料，Athena 僅保留毫秒精度。
+ **不支援的操作** – Iceberg 資料表不支援以下 Athena 操作。
  + [ALTER TABLE SET LOCATION](alter-table-set-location.md)
+ **Views** (檢視) – 使用 `CREATE VIEW` 建立 Athena 檢視，如 [使用檢視](views.md) 中所述。如果您有興趣使用 [Iceberg 檢視規格](https://github.com/apache/iceberg/blob/master/format/view-spec.md)來建立檢視，請聯絡 [athena-feedback@amazon.com](mailto:athena-feedback@amazon.com)。
+ ** AWS Lake Formation中不支援 TTF 管理命令** – 雖然您可以使用 Lake Formation 來管理 TransactionTable Formats (TTF) 的讀取存取許可，例如 Apache Iceberg、Apache Hudi 和 Linux Foundation Delta Lake，但您無法使用 Lake Formation 來管理操作的許可，例如使用這些資料表格式的 `VACUUM`、`MERGE`、`UPDATE` 或 `OPTIMIZE`。如需 Lake Formation 與 Athena 整合的詳細資訊，請參閱《 *AWS Lake Formation 開發人員指南*》中的[搭配使用 AWS Lake Formation 與 Amazon Athena](https://docs.aws.amazon.com/lake-formation/latest/dg/athena-lf.html)。
+ **依巢狀欄位分割** – 不支援依巢狀欄位分割。嘗試這樣做會產生訊息 NOT\_SUPPORTED：不支援依巢狀欄位分割：{{column\_name}}.{{nested\_field\_name}}。
+ **略過不支援的 Amazon Glacier 物件** – 如果 Apache Iceberg 資料表中的物件位於 Amazon Glacier 儲存類別中，則將 `read_restored_glacier_objects` 資料表屬性設定為 `false` 是無效的。

  例如，假設您發出下列命令：

  ```
  ALTER TABLE {{table_name}} SET TBLPROPERTIES ('read_restored_glacier_objects' = 'false')
  ```

  對於 Iceberg 和 Delta Lake 資料表，此命令會產生錯誤不支援的資料表屬性索引鍵：read\_restored\_glacier\_objects。對於 Hudi 資料表，`ALTER TABLE` 命令不會產生錯誤，但是 Amazon Glacier 物件仍不會略過。在 `ALTER TABLE` 命令繼續傳回所有物件之後執行 `SELECT` 查詢。

如果您希望 Athena 支援特定功能，請將意見回饋傳送至 [athena-feedback@amazon.com](mailto:athena-feedback@amazon.com)。

**Topics**
+ [考量和限制](#querying-iceberg-considerations-and-limitations)
+ [建立 Iceberg 資料表](querying-iceberg-creating-tables.md)
+ [查詢 Iceberg 資料表資料](querying-iceberg-table-data.md)
+ [執行時間歷程和版本歷程查詢](querying-iceberg-time-travel-and-version-travel-queries.md)
+ [更新 Iceberg 資料表資料](querying-iceberg-updating-iceberg-table-data.md)
+ [管理 Iceberg 資料表](querying-iceberg-managing-tables.md)
+ [演進 Iceberg 資料表結構描述](querying-iceberg-evolving-table-schema.md)
+ [在 Iceberg 資料表上執行其他 DDL 操作](querying-iceberg-additional-operations.md)
+ [最佳化 Iceberg 資料表](querying-iceberg-data-optimization.md)
+ [查詢 AWS Glue Data Catalog 具體化視觀表](querying-iceberg-gdc-mv.md)
+ [Athena 中 Iceberg 資料表支援的資料類型](querying-iceberg-supported-data-types.md)
+ [其他資源](querying-iceberg-additional-resources.md)