From ba93b6b84ebbafcd237b9b3633637b9147c3e011 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 22 Oct 2020 23:07:17 -0400 Subject: [PATCH] replace hardcoded table name to derive from target meta --- sql/build_master_tables.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/build_master_tables.sql b/sql/build_master_tables.sql index 5ffbf9c..6961ab3 100644 --- a/sql/build_master_tables.sql +++ b/sql/build_master_tables.sql @@ -14,12 +14,13 @@ BEGIN ', PRIMARY KEY ('||string_agg(format('%I',cname),', ') FILTER (WHERE fkey = func)||'));' AS ddl, -------------------------------------------populate table------------------------------------------------------------------------------------------------------- ---need to add a clause to exclude where the key is null - 'INSERT INTO fc.'||func||' SELECT DISTINCT ' || string_agg(format('%I',cname),', ' ORDER BY opos ASC) || ' FROM rlarp.osm_dev WHERE '|| + 'INSERT INTO fc.'||func||' SELECT DISTINCT ' || string_agg(format('%I',cname),', ' ORDER BY opos ASC) || ' FROM '||tname||' WHERE '|| string_agg(format('%I',cname)||' IS NOT NULL ',' AND ') FILTER (WHERE fkey = func)||' ON CONFLICT DO NOTHING' AS pop FROM fc.target_meta GROUP BY - func + tname + ,func HAVING string_agg(cname,', ') FILTER (WHERE fkey = func) <> '' loop