Yes, i have used it for a long, but it was always wellformed, so malformed query was some kind of surprise.
select format('insert into x.y ( field, ... ) select val, ... from %I.%I on conflict ( constraint ) do nothing;\dti+ x.y*', (regexp_match(tablename, '\d[\d_]+$'))[1], schemaname, tablename) from pg_tables where schemaname = 'x' and tablename ~ '^y' order by 1;
insert into x.y ( field, ... ) select '2020_07_29'::date, field, ... from x.y_archive_2020_07_29 on conflict ( constraint ) do nothing;\dti+ x.y_new_scheme*
insert into x.y ( field, ... ) select '2020_08_05'::date, field, ... from x.y_archive_2020_08_05 on conflict ( constraint ) do nothing;\dti+ x.y_new_scheme*
insert into x.y ( field, ... ) select '2020_08_12'::date, field, ... from x.y_archive_2020_08_12 on conflict ( constraint ) do nothing;\dti+ x.y_new_scheme*
\gexec
Aleksey M Boltenkov.