0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Redshift Serverless に S3 からデータをロードしてみた

0
Posted at

背景・目的

前回、CDKでResdshift Serverlessを作成しました。今回は作成したDDLに対してデータをロードしたときのメモになります。

実践

事前準備

  1. データロード用のS3を作成します
  2. データロード用のS3を読み込めるIAMロールを作成します
  3. NameSpaceに上記のIAMロールを紐づけます

テストデータを用意

  1. ローカルにCSVファイルを準備します
  2. テーブル名ごとに、S3にCSVファイルをアップします
    image.png

データロード

COPY コマンドで S3 から Redshift にデータをロードします。

  1. 下記のコマンドでコピーします
COPY <スキーマ名>.<テーブル名>
FROM '<S3パス>'
IAM_ROLE default
CSV
IGNOREHEADER 1
TIMEFORMAT 'auto'
DATEFORMAT 'auto';

考察

  • COPY コマンドは INSERT と比べて大量データのロードに適している(S3 から並列で読み込むため高速)
  • IAM_ROLE default を使うことで、COPY コマンドに ARN を直接書く必要がなくなる
  • テーブルごとに S3 のパスを分けておくと、ロードの管理がしやすい

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?