MERGE Statement with FILTER

0

Hello Team, I am trying to use a merge statement to merge data from the glue catalog to redshift tabes. The requirement is to merge records and have a filter clause

For example: Here where the clause does not work MERGE INTO target_table USING <glue catalog table - which gets copied into temp table> WHERE source_table.column = 'value' ON ...


I also tried using and as a predicate but it merged the record with id 0001230

MERGE INTO TARGET TABLE USING #temp_table src ON TARGET.id = src.id and src.id != '0001230' WHEN MATCHED THEN UPDATE SET

how should I add a filter in the merge statement?

gefragt vor 3 Monaten141 Aufrufe
2 Antworten
0

Hi,

Currently Redshift MERGE statements do not allow for the source table to be a view, subquery, or CTE (created by a WITH statement). If you need to perform some filtering on the source table before applying the MERGE you will need to create a permanent or temporary table to be used as the source.

Alternatively you can use UPDATE and INSERT statements.

profile pictureAWS
EXPERTE
beantwortet vor 3 Monaten
-1

I would just use a WITH clause before the merge to filter the source table before the merge.

profile pictureAWS
EXPERTE
beantwortet vor 3 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen