RedShift: psycopg2.errors.UndefinedTable: invalid reference to FROM-clause entry for table

Всем привет.

Не имею пока что большого опыта работы с RedShift и поэтому не могу понять что сделал не так.

Вот мой запрос:

begin transaction;
-- Update records
UPDATE target.table AS t
SET project_number = s.number, project_name = s.name, connect_project_id = s.connect_project_id, project_desc = s.description,
            project_type = s.type, project_status = s.status, project_path = s.path, language_code = s.language,
            country_code = s.country, timezone = s.timezone, date_created = s.created, date_updated = s.modified,
            edw_date_updated = getdate()       
FROM source.table AS s
WHERE t.collect_project_id = s.id AND (s.created > getdate() - interval '30 minutes' OR s.modified > getdate() - interval '30 minutes');

-- Insert records
INSERT INTO target.table (
            collect_project_id,
            project_number,
            project_name,
            connect_project_id,
            project_desc,
            project_type,
            project_status,
            project_path,
            language_code,
            country_code,
            timezone,
            date_created,
            date_updated
            )
(SELECT id, number, name, connect_project_id, description, type, status, path, language, country, timezone, created, modified
FROM source.table
WHERE target.table.collect_project_id != source.table.id AND (source.table.created > getdate() - interval '30 minutes' OR source.table.modified > getdate() - interval '30 minutes'));

end transaction;

В общем-то простой запрос, но какие-то постоянные с этим RedShift бока вылезают.

Сейчас ошибка такая:

psycopg2.errors.UndefinedTable: invalid reference to FROM-clause entry for table "target.table" HINT: There is an entry for table "target.table", but it cannot be referenced from this part of the query.


Ответы (0 шт):