我正在尝试向 RedShift 添加数据的请求:
-- 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
LEFT JOIN target.table
ON source.table.id = target.table.collect_project_id
WHERE target.table.collect_project_id != source.table.projects.id AND (source.table.created > getdate() - interval '30 minutes' OR source.table.modified > getdate() - interval '30 minutes'));
我收到一个错误:
psycopg2.errors.AmbiguousColumn: column reference "connect_project_id" is ambiguous
在 select 中明确指定要从哪个表中获取列
connect_project_id,即 或在选择中,替换connect_project_id为target.table.connect_project_id或source.table.connect_project_id。