

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

# Amazon SageMaker Feature Store 離線儲存資料格式
<a name="feature-store-offline"></a>

Amazon SageMaker Feature Store 支援離線存放區的 AWS Glue 和 Apache Iceberg 資料表格式。您可以在建立新功能群組時選擇資料表格式。 AWS Glue 是預設格式。

 Amazon SageMaker Feature Store 離線儲存資料存放在您的帳戶內的 Amazon S3 儲存貯體。呼叫 `PutRecord` 時，您的資料會在 15 分鐘內緩衝、批次處理並寫入 Amazon S3。特徵商店僅在將資料寫入離線儲存時支援 Parquet 檔案格式。具體而言，當您將資料寫入離線儲存時，就可以從 Amazon S3 儲存貯體以 Parquet 格式擷取資料。每個檔案可以包含多個 `Record`。

對於 Iceberg 格式，Feature Store 會將資料表的中繼資料儲存在您用來存放離線儲存資料的同一個 Amazon S3 儲存貯體中。您可以在 `metadata` 字首下找到它。

 特徵商店也會公開 [OfflineStoreConfig.S3StorageConfig.ResolvedOutputS3Uri ](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_S3StorageConfig.html#sagemaker-Type-S3StorageConfig-ResolvedOutputS3Uri) 欄位，您可以在 [DescribeFeatureGroup](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeFeatureGroup.html) API 呼叫中找到。這是寫入特定特徵群組檔案的 S3 路徑。

當以下附加欄位保留在離線儲存中時，特徵商店會將其新增至每條記錄中：
+  **api\_invocation\_time** – 服務接收 `PutRecord` 或 `DeleteRecord` 呼叫時的時間戳記。如果使用受管擷取 (例如 Data Wrangler)，這是將資料寫入離線儲存的時間戳記。
+  **write\_time** – 資料寫入離線儲存時的時間戳記。可用於構建與時間歷程相關的查詢。
+  **is\_deleted** – 預設為 `False`。如果呼叫 `DeleteRecord`，則會在離線儲存中將新 `Record` 插入 `RecordIdentifierValue`，並將其設定為 `True`。

## Amazon SageMaker Feature Store 離線儲存 URI 結構
<a name="feature-store-offline-URI-structure"></a>

在下列範例中，`amzn-s3-demo-bucket` 是您帳戶中的 Amazon S3 儲存貯體，`{{example-prefix}}` 是您的範例字首，`{{111122223333}}` 是您的帳戶 ID，`{{AWS 區域}}` 是您的區域，`{{feature-group-name}}` 是特徵群組的名稱。

**AWS Glue 資料表格式**

使用 AWS Glue 資料表格式存放的離線存放區中的記錄會依事件時間分割為每小時分割區。您無法設定分割結構。以下 URI 結構顯示了使用 AWS Glue 格式的 Parquet 檔案的組織：

```
s3://amzn-s3-demo-bucket/{{example-prefix}}/{{111122223333}}/sagemaker/{{AWS 區域}}/offline-store/{{feature-group-name}}-{{feature-group-creation-time}}/data/year={{year}}/month={{month}}/day={{day}}/hour={{hour}}/{{timestamp_of_latest_event_time_in_file}}_{{16-random-alphanumeric-digits}}.parquet
```

以下範例是 `{{feature-group-name}}` 為 `customer-purchase-history-patterns` 的檔案的 Parquet 檔案的輸出位置：

```
s3://amzn-s3-demo-bucket/{{example-prefix}}/{{111122223333}}/sagemaker/{{AWS 區域}}/offline-store/customer-purchase-history-patterns-1593511200/data/year=2020/month=06/day=31/hour=00/20200631T064401Z_108934320012Az11.parquet
```

**Iceberg 資料表格式**

使用 Iceberg 資料表格式儲存的離線儲存中的記錄會依事件時間分割成每日分割區。您無法設定分割結構。以下 URI 結構顯示了以 Iceberg 資料表格式儲存的資料檔案的組織：

```
s3://amzn-s3-demo-bucket/{{example-prefix}}/{{111122223333}}/sagemaker/{{AWS 區域}}/offline-store/{{feature-group-name}}-{{feature-group-creation-time}}/data/{{8-random-alphanumeric-digits}}/{{event-time-feature-name}}_trunc={{event-time-year}}-{{event-time-month}}-{{event-time-day}}/timestamp-of-latest-event-time-in-file_16-random-alphanumeric-digits.parquet
```

以下範例是 `{{feature-group-name}}` 為 `customer-purchase-history-patterns`，以及 `{{event-time-feature-name}}` 為 `EventTime` 的檔案的 Parquet 檔案的輸出位置：

```
s3://amzn-s3-demo-bucket/{{example-prefix}}/{{111122223333}}/sagemaker/{{AWS 區域}}/offline-store/customer-purchase-history-patterns-1593511200/data/0aec19ca/EventTime_trunc=2022-11-09/20221109T215231Z_yolTtpyuWbkaeGIl.parquet
```

下列範例是以 Iceberg 資料表格式儲存資料檔案的中繼資料檔案位置。

```
s3://amzn-s3-demo-bucket/{{example-prefix}}/{{111122223333}}/sagemaker/{{AWS 區域}}/offline-store/{{feature-group-name}}-{{feature-group-creation-time}}/metadata/
```