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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则