查询还原的 Amazon S3 Glacier 对象 - Amazon Athena
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

查询还原的 Amazon S3 Glacier 对象

您可以使用 Athena 查询从 S3 Glacier Flexible Retrieval(以前称为 Glacier)和 S3 Glacier Deep Archive Amazon S3 存储类还原的对象。必须针对每个表启用此功能。如果您在运行查询之前未在表上启用该功能,Athena 将在查询执行期间跳过该表的所有 S3 Glacier Flexible Retrieval 和 S3 Glacier Deep Archive 对象。

注意事项和限制

  • 只有 Athena 引擎版本 3 支持查询还原的 Amazon S3 Glacier 对象。

  • 只有 Apache Hive 表支持该功能。

  • 在查询数据之前,您必须还原对象;Athena 不会为您还原对象。

将表配置为使用已还原的对象

要将 Athena 表配置为在查询中包含还原的对象,必须将其 read_restored_glacier_objects 表属性设置为 true。为此,您可以使用 Athena 查询编辑器或 Amazon Glue 控制台。您还可以使用 Amazon Glue CLIAmazon Glue APIAmazon Glue SDK

使用 Athena 查询编辑器

在 Athena 中,您可以使用 ALTER TABLE SET TBLPROPERTIES 命令来设置表属性,如下例所示。

ALTER TABLE table_name SET TBLPROPERTIES ('read_restored_glacier_objects' = 'true')

使用 Amazon Glue控制台

在 Amazon Glue 控制台中,执行以下步骤添加 read_restored_glacier_objects 表属性。

在 Amazon Glue 控制台中配置表属性
  1. 登录 Amazon Web Services Management Console,然后打开 Amazon Glue 控制台,网址为:https://console.aws.amazon.com/glue/

  2. 请执行以下操作之一:

    • 选择转到数据目录

    • 在导航窗格中,选择数据目录表

  3. 页面的表列表中+,选择要编辑的表的链接。

  4. 依次选择 Actions(操作)、Edit table(编辑表)。

  5. 编辑表页面的表属性部分中,添加以下键值对:

    • 对于 Key (键),添加 read_restored_glacier_objects

    • 对于 Value(值),输入 true

  6. 请选择保存

使用 Amazon CLI

在 Amazon CLI 中,您可以使用 Amazon Glue update-table 命令及其 --table-input 参数来重新定义表,并在此过程中添加 read_restored_glacier_objects 属性。在 --table-input 参数中,使用 Parameters 结构来指定 read_restored_glacier_objects 属性和 true 值。请注意:--table-input 的参数不能有空格,并且必须使用反斜杠来转义双引号。在以下示例中,将 my_databasemy_table 替换为数据库和表的名称。

aws glue update-table \ --database-name my_database \ --table-input={\"Name\":\"my_table\",\"Parameters\":{\"read_restored_glacier_objects\":\"true\"}}
重要

Amazon Glue update-table 命令在覆盖模式下运行,这意味着其将用 table-input 参数指定的新定义替换现有的表定义。因此,在添加 read_restored_glacier_objects 属性时,请务必在 table-input 参数中指定希望表中包含的所有字段。