

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Amazon SageMaker Feature Store 线下商店数据格式
<a name="feature-store-offline"></a>

Amaz SageMaker on Feature Store 支持线下商店的 AWS Glue 和 Apache Iceberg 表格格式。创建新要素组时，您可以选择表格格式。 AWS Glue 是默认格式。

 Amaz SageMaker on Feature Store 离线商店数据存储在您账户中的 Amazon S3 存储桶中。当您调用 `PutRecord` 时，系统会在 15 分钟内对数据进行缓冲、批处理并将其写入 Amazon S3。Feature Store 仅在将数据写入离线存储时支持 Parquet 文件格式。具体来说，当数据写入离线存储时，可以从 Amazon S3 存储桶中检索到 Parquet 格式的数据。每个文件可以包含多个 `Record`。

对于 Iceberg 格式，Feature Store 会将表的元数据保存在您用来存储离线存储数据的同一 Amazon S3 存储桶中。您可以在 `metadata` 前缀下找到它。

 功能商店还公开了 [OfflineStoreConfig.S3。StorageConfig 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 路径。

当每条记录在离线存储中持续存在时，Feature Store 会将以下附加字段添加到这些记录中：
+  **api\$1invocation\$1time** - 服务接收 `PutRecord` 或 `DeleteRecord` 调用时的时间戳。如果使用托管摄取（例如 Data Wrangler），则这是将数据写入离线存储时的时间戳。
+  **write\$1time** - 将数据写入离线存储时的时间戳。可用于构造与时间旅行相关的查询。
+  **is\$1deleted** - 默认情况下为 `False`。如果调用了 `DeleteRecord`，则会在 `RecordIdentifierValue` 中插入一个新 `Record` 并在离线存储中将其设置为 `True`。

## 亚马逊 SageMaker 功能商店线下商店 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/
```