Как заменить ON CONFLICT в RedShift?
Как правильно заменить в RedShift параметр ON CONFLICT при попытке обновить данные в строке, если нашли дубликат? Потому что как я понял, RedShift не воскпринимает ON CONFLICT. Во всяком случае у меня выдает ошибку на этот параметр.
Ответы (1 шт):
Автор решения: Viktor Andriichuk
→ Ссылка
Сейчас заменил так (взял из официальной документации):
begin transaction;
update target
set col1 = stage.col1,
col2 = stage.col2,
col3 = 'expression'
from stage
where target.primarykey = stage.primarykey
and target.distkey = stage.distkey
and target.col3 > 'last_update_time'
and (target.col1 != stage.col1
or target.col2 != stage.col2
or target.col3 = 'filter_expression');
insert into target
(select col1, col2, 'expression'
from stage);
end transaction;