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?

preguntada hace 3 meses138 visualizaciones
2 Respuestas
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
EXPERTO
respondido hace 3 meses
-1

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

profile pictureAWS
EXPERTO
respondido hace 3 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas