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?

질문됨 3달 전138회 조회
2개 답변
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
전문가
답변함 3달 전
-1

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

profile pictureAWS
전문가
답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠