SORTKEY / DISTKEY When writing data to redshift using AWS Glue

0

How do I add a sort / dist key to the glue dynamicframe writer into redshift?

質問済み 3ヶ月前159ビュー
1回答
0

That is part of the table DDL, not the writing itself.
You could have the table previously created with the sort/dist keys as needed, or if you need to create the table dynamically, you could add a preaction to create the table as needed or a post action to alter the table to do that tweaking

profile pictureAWS
エキスパート
回答済み 3ヶ月前
  • I've tried using a post-action like this:,

    datasink = glueContext.write_dynamic_frame.from_options(
        frame=dyf,
        connection_type="redshift",
        connection_options={
            "redshiftTmpDir": "..",
            "dbtable": "..",
            "connectionName": "..",
            "postactions": "ALTER TABLE <TABLE> ALTER DISTSTYLE KEY DISTKEY <DIST-COLUMN>, ALTER SORTKEY (<SORT-COLUM-A>, <SORT-COLUMN-B>);"
        },
        transformation_ctx="..",
    )
    

    but the problem with specifying them for this problem is that everything works fine the first time the table is created. On subsequent runs, the job fails because you cannot specify THE SAME sort / dist key on the table.

    So is there a way to suppress or ignore errors from the post-actions?

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ