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?

posta 3 mesi fa159 visualizzazioni
1 Risposta
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
ESPERTO
con risposta 3 mesi fa
  • 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?

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande