

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

# 查詢向 Lake Formation 註冊之資料的考量事項與限制
<a name="lf-athena-limitations"></a>

使用 Athena 查詢在 Lake Formation 中註冊的資料時請考慮以下項目。如需其他資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [AWS Lake Formation的已知問題](https://docs.aws.amazon.com/lake-formation/latest/dg/limitations.html)。

**Topics**
+ [在某些情況下，沒有資料欄資料許可的使用者可以看見資料欄中繼資料](#lf-athena-limitations-column-metadata)
+ [使用檢視的 Lake Formation 許可](#lf-athena-limitations-permissions-to-views)
+ [Iceberg DDL 支援](#lf-athena-limitations-iceberg-ddl-operations)
+ [Lake Formation 精細存取控制和 Athena 工作群組](#lf-athena-limitations-fine-grained-access-control)
+ [Amazon S3 中的 Athena 查詢結果位置未向 Lake Formation 註冊](#lf-athena-limitations-query-results-location)
+ [使用 Athena 工作群組限制查詢歷史記錄的存取](#lf-athena-limitations-use-workgroups-to-limit-access-to-query-history)
+ [無法在 Athena 中查詢向 Lake Formation 註冊的 CSE-KMS Amazon S3](#lf-athena-limitations-cse-kms)
+ [向 Lake Formation 註冊的分割資料位置必須位於資料表子目錄中](#lf-athena-limitations-partioned-data-locations)
+ [Create Table As Select (CTAS) 查詢需要 Amazon S3 寫入許可](#lf-athena-limitations-ctas-queries)
+ [預設資料庫需要 DESCRIBE 許可](#lf-athena-limitations-describe-default)

## 在某些情況下，未經授權的使用者利用 Avro 和自訂 SerDe 可以看見資料欄中繼資料
<a name="lf-athena-limitations-column-metadata"></a>

Lake Formation 資料欄層級授權可防止沒有 Lake Formation 許可的使用者存取資料欄中的資料。不過，在某些情況下，使用者可以存取描述資料表中所有資料欄的中繼資料，包括他們沒有資料許可的資料欄。

此情形會在資料欄中繼資料存放在資料表的資料表屬性中時發生，使用 Apache Avro 儲存格式或使用自訂序列化程式/還原序列化程式 (SerDe)，其中資料表結構描述與 SerDe 定義已一併在資料表屬性中定義。搭配 Lake Formation 使用 Athena 時，我們建議您檢閱向 Lake Formation 註冊的資料表屬性內容，並盡可能限制資料表屬性中所存放的資訊，以防止使用者看到任何敏感中繼資料。

## 了解 Lake Formation 和視觀表
<a name="lf-athena-limitations-permissions-to-views"></a>

對於向 Lake Formation 註冊的資料，Athena 使用者只有在擁有資料表、資料欄，以及來源 Simple Storage Service (Amazon S3) 資料位置 (此為 `VIEW` 之根據) 之 Lake Formation 許可時，才能建立 `VIEW`。在 Athena 中建立 `VIEW` 之後，Lake Formation 許可即可套用至 `VIEW`。資料欄層級許可不適用於 `VIEW`。具有 `VIEW` 的 Lake Formation 許可，但沒有資料表和資料欄許可 (此為檢視之根據) 的使用者，無法使用 `VIEW` 來查詢資料。不過，具有此混合許可的使用者可以使用陳述式 (例如 `DESCRIBE VIEW`、`SHOW CREATE VIEW` 和 `SHOW COLUMNS`) 來查看 `VIEW` 中繼資料。因此，請務必針對每個 `VIEW` 調整 Lake Formation 許可以符合基礎資料表的許可。在資料表中定義的儲存格篩選條件不適用於針對該資料表的 `VIEW`。資源連結名稱必須與原始帳戶中的資源名稱相同。在跨帳戶設定中使用檢視時，還會有其他限制。如需有關設定跨帳戶的共用視圖的許可的詳細資訊，請參閱[設定跨帳戶 Data Catalog 存取權](lf-athena-limitations-cross-account.md)。

## Iceberg DDL 支援
<a name="lf-athena-limitations-iceberg-ddl-operations"></a>

Athena 目前不支援位置已向 Lake Formation 註冊的 Iceberg 資料表執行 DDL 操作。嘗試對其中一個 Iceberg 資料表執行 DDL 查詢可能會傳回 Amazon S3 存取遭拒錯誤，或因查詢逾時失敗。Iceberg 資料表上的 DDL 操作要求使用者擁有對 Iceberg 資料表位置的直接 Amazon S3 存取權。

## Lake Formation 精細存取控制和 Athena 工作群組
<a name="lf-athena-limitations-fine-grained-access-control"></a>

同一 Athena 工作群組中的使用者可以看到 Lake Formation 精細存取控制設定為可供工作群組存取的資料。如需有關在 Lake Formation 中使用精細定義存取控制的詳細資訊，請參閱 *AWS 大數據部落格*中的[使用 AWS Lake Formation管理精細定義存取控制](https://aws.amazon.com/blogs/big-data/manage-fine-grained-access-control-using-aws-lake-formation/)。

## Amazon S3 中的 Athena 查詢結果位置未向 Lake Formation 註冊
<a name="lf-athena-limitations-query-results-location"></a>

Simple Storage Service (Amazon S3) 中的 Athena 查詢結果無法向 Lake Formation 註冊。Lake Formation 許可不會限制對這些位置的存取。除非您限制存取，否則 Athena 使用者可以在沒有 Lake Formation 的資料許可時存取查詢結果檔案和中繼資料。若要避免這種情況，我們建議您使用工作群組來指定查詢結果的位置，並使工作群組成員資格與 Lake Formation 許可保持一致。然後，您可以使用 IAM 許可政策來限制查詢結果位置的存取。如需有關查詢結果的詳細資訊，請參閱[使用查詢結果和近期查詢](querying.md)。

## 使用 Athena 工作群組限制查詢歷史記錄的存取
<a name="lf-athena-limitations-use-workgroups-to-limit-access-to-query-history"></a>

Athena 查詢歷史記錄會公開已儲存查詢和完整查詢字串的清單。除非您使用工作群組來分隔查詢歷程記錄的存取權限，否則未獲授權在 Lake Formation 中查詢資料的 Athena 使用者可以檢視對該資料執行的查詢字串，包括資料欄名稱、選取準則等。我們建議您使用工作群組來分隔查詢歷程記錄，並使 Athena 工作群組成員資格與 Lake Formation 許可保持一致，以限制存取。如需詳細資訊，請參閱[使用工作群組來控制查詢存取和成本](workgroups-manage-queries-control-costs.md)。

## 查詢向 Lake Formation 註冊的 CSE\$1KMS 加密資料表
<a name="lf-athena-limitations-cse-kms"></a>

無法使用 Athena 查詢具有下列特性的開放資料表格式 (OTF) 資料表，例如 Apache Iceberg：
+ 這些資料表以向 Lake Formation 註冊的 Amazon S3 資料位置為基礎。
+ 使用用戶端加密 (CSE) 對 Amazon S3 中的物件進行加密。
+ 加密使用 AWS KMS 客戶受管金鑰 (`CSE_KMS`)。

若要查詢使用`CSE_KMS`金鑰加密的非OTF 資料表，請將下列區塊新增至您用於 CSE 加密的 AWS KMS 金鑰政策。*<KMS\$1KEY\$1ARN>* 是加密資料的 AWS KMS 金鑰 ARN。*<IAM-ROLE-ARN>* 是 Lake Formation 中註冊 Amazon S3 位置的 IAM 角色的 ARN。

```
{
    "Sid": "Allow use of the key",
    "Effect": "Allow",
    "Principal": {
        "AWS": "*"
    },
    "Action": "kms:Decrypt",
    "Resource": "<KMS-KEY-ARN>",
    "Condition": {
        "ArnLike": {
            "aws:PrincipalArn": "<IAM-ROLE-ARN>"
        }
    }
}
```

## 向 Lake Formation 註冊的分割資料位置必須位於資料表子目錄中
<a name="lf-athena-limitations-partioned-data-locations"></a>

向 Lake Formation 註冊的分割資料表必須在目錄中擁有分割資料，這些目錄是 Simple Storage Service (Amazon S3) 中資料表的子目錄。例如，具有 `s3://amzn-s3-demo-bucket/mytable` 位置和分割區 `s3://amzn-s3-demo-bucket/mytable/dt=2019-07-11`、`s3://amzn-s3-demo-bucket/mytable/dt=2019-07-12` 等的資料表，可以向 Lake Formation 註冊並使用 Athena 進行查詢。另一方面，位置 `s3://amzn-s3-demo-bucket/mytable` 的資料表和位於 `s3://amzn-s3-demo-bucket/dt=2019-07-11`、`s3://amzn-s3-demo-bucket/dt=2019-07-12` 等的分割區，無法向 Lake Formation 註冊。此類分割區不是 `s3://amzn-s3-demo-bucket/mytable` 的子目錄，因此也無法從 Athena 讀取。

## Create Table As Select (CTAS) 查詢需要 Amazon S3 寫入許可
<a name="lf-athena-limitations-ctas-queries"></a>

Create Table As Statements (CTAS) 需要對資料表的 Simple Storage Service (Amazon S3) 位置的寫入存取權限。若要對在 Lake Formation 註冊的資料執行 CTAS 查詢，Athena 使用者除了適當的 Lake Formation 許可以讀取資料位置之外，還必須具有 IAM 許可才能寫入資料表 Simple Storage Service (Amazon S3) 位置。如需詳細資訊，請參閱[從查詢結果建立資料表 (CTAS)](ctas.md)。

## 預設資料庫需要 DESCRIBE 許可
<a name="lf-athena-limitations-describe-default"></a>

`default` 資料庫需要 Lake Formation `DESCRIBE` 許可，如此 Lake Formation 才能檢視該資料庫。下列範例 AWS CLI 命令會將`default`資料庫的 `DESCRIBE`許可授予 AWS 帳戶 `datalake_user1`中的使用者`111122223333`。

```
aws lakeformation grant-permissions --principal DataLakePrincipalIdentifier=arn:aws:iam::111122223333:user/datalake_user1 --permissions "DESCRIBE" --resource '{ "Database": {"Name":"default"}}
```

如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [DESCRIBE](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html#perm-describe)。