如何将 Amazon Athena 表直接复制到 Amazon Redshift 中?

tik*_*run 0 amazon-s3 amazon-web-services amazon-redshift amazon-athena

我在 S3 中有一些 JSON 文件,我能够从这些数据文件在 Amazon Athena 中创建数据库和表。大功告成,我的下一个目标是将这些创建的表复制到 Amazon Redshift 中。我根据这些数据文件在 Amazon Athena 中创建了其他表。我的意思是我使用 S3 中的那些数据文件创建了三个表,后者我使用这 3 个表创建了新表。所以目前我有 5 个不同的表,想要在 Amazon Redshift 中创建有数据或没有数据的表。

我检查了Amazon Redshift 中COPY命令,但没有Amazon Athena 的COPY 命令。以下是可用列表。

  • 从 Amazon S3 复制
  • 从亚马逊 EMR 复制
  • 从远程主机 (SSH) 复制
  • 从 Amazon DynamoDB 复制

如果没有其他解决方案,我计划基于 Amazon Athena 中新创建的表创建新的 JSON 文件到 S3 存储桶中。然后我们可以轻松地将那些从 S3 复制到 Redshift 中,不是吗?有没有其他好的解决方案?

Jon*_*ott 5

如果您的 s3 文件格式正常,您可以使用 Redshift Spectrum。

1) 为您的 s3 文件设置一个 hive 元数据目录,如果您愿意,可以使用 aws 胶水。

2)设置 Redshift Spectrum 以查看 redshift 中的数据(https://docs.aws.amazon.com/redshift/latest/dg/c-getting-started-using-spectrum.html

3)使用CTAS在redshift里面创建一个副本

create table redshift_table as select * from redshift_spectrum_schema.redshift_spectrum_table;
Run Code Online (Sandbox Code Playgroud)