-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproc.sql
More file actions
17 lines (12 loc) · 825 Bytes
/
proc.sql
File metadata and controls
17 lines (12 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
create or replace procedure copy_in(folder text) as $$
declare n_partitions int;
begin
drop table if exists catalog_substance_cat_t;
create table catalog_substance_cat_t (sub_id_fk bigint, cat_content_fk bigint, grp_id int, nope bigint) partition by hash(cat_content_fk);
call create_table_partitions('catalog_substance_cat_t', '');
-- import /nfs/exb/zinc22/upload_diffs/freedom/n-9-38:5440/catsub/combined first 2 cols into catalog_substance_cat
execute(format('copy catalog_substance_cat_t(sub_id_fk, cat_content_fk, grp_id, nope) from ''%s'' with delimiter as E''\t'' null as ''\N''', folder));
insert into catalog_substance_cat(select sub_id_fk, cat_content_fk from catalog_substance_cat_t);
drop table if exists catalog_substance_cat_t;
end $$ language plpgsql;
call copy_in(:'folder');