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?

feita há 3 meses159 visualizações
1 Resposta
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
ESPECIALISTA
respondido há 3 meses
  • 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?

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas