

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

# 使用 Athena 產生的路徑擷取器
<a name="ion-serde-generated-path-extractors"></a>

依預設，Athena 會搜尋與 Hive 資料欄名稱相符的頂層 Amazon Ion 值，並根據這些相符的值在執行時間建立路徑擷取器。如果您的 Amazon Ion 資料格式與 Hive 資料表結構描述相符，Athena 會為您動態產生擷取器，並且您無需新增任何其他路徑擷取器。這些預設路徑擷取器不會存放在資料表中繼資料中。

下列範例說明了 Athena 如何根據資料欄名稱產生擷取器。

```
-- Example Amazon Ion Document
{
    identification: {
        name: "John Smith",
        driver_license: "XXXX"
    },
    
    alias: "Johnny"    
}

-- Example DDL
CREATE EXTERNAL TABLE example_schema2 (
    identification MAP<STRING, STRING>,
    alias STRING
)
STORED AS ION
LOCATION 's3://amzn-s3-demo-bucket/path_extraction1/'
```

下列範例擷取器由 Athena 產生。第一個會將 `identification` 欄位擷取為 `identification` 資料欄，第二個會將 `alias` 欄位擷取為 `alias` 資料欄。

```
'ion.identification.path_extractor' = '(identification)'
'ion.alias.path_extractor' = '(alias)'
```

下列範例說明了擷取的資料表。

```
|                  identification                    |  alias   |
|----------------------------------------------------|----------|
|{["name", "driver_license"],["John Smith", "XXXX"]} | "Johnny" |
```