adjust column names outputed so they match destination table names

This commit is contained in:
Paul Trowbridge 2023-03-24 22:28:00 -04:00
parent d2dbe2deb1
commit 83bea18a4c
2 changed files with 65 additions and 63 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ node_modules/*
*.log
*.pem
.vscode/
*.swp

View File

@ -1,12 +1,13 @@
DROP FUNCTION IF EXISTS tps.report_unmapped_recs;
CREATE FUNCTION tps.report_unmapped_recs(_srce text) RETURNS TABLE
(
source text,
map text,
ret_val jsonb,
"count" bigint,
recs jsonb
srce text,
target text,
retval jsonb,
map jsonb,
hist jsonb,
cnt bigint,
recs jsonb
)
LANGUAGE plpgsql
AS
@ -120,16 +121,16 @@ rx AS (
, agg_to_target_items AS (
SELECT
srce
,id
,rec
,target
,seq
,map_intention
,regex_function
,target_item_number
,result_key_name
,target_json_path
rx.srce
,rx.id
,rx.rec
,rx.target
,rx.seq
,rx.map_intention
,rx.regex_function
,rx.target_item_number
,rx.result_key_name
,rx.target_json_path
,CASE WHEN map_key IS NULL
THEN
NULL
@ -161,18 +162,18 @@ SELECT
FROM
rx
GROUP BY
srce
,id
,rec
,target
,seq
,map_intention
,regex_function
,target_item_number
,result_key_name
,target_json_path
,map_key
,retain_key
rx.srce
,rx.id
,rx.rec
,rx.target
,rx.seq
,rx.map_intention
,rx.regex_function
,rx.target_item_number
,rx.result_key_name
,rx.target_json_path
,rx.map_key
,rx.retain_key
)
--SELECT * FROM agg_to_target_items LIMIT 100
@ -180,45 +181,43 @@ GROUP BY
, agg_to_target AS (
SELECT
srce
,id
,rec
,target
,seq
,map_intention
a.srce
,a.id
,a.rec
,a.target
,a.seq
,a.map_intention
,tps.jsonb_concat_obj(COALESCE(map_val,'{}'::JSONB)) map_val
,jsonb_strip_nulls(tps.jsonb_concat_obj(COALESCE(retain_val,'{}'::JSONB))) retain_val
FROM
agg_to_target_items
agg_to_target_items a
GROUP BY
srce
,id
,rec
,target
,seq
,map_intention
a.srce
,a.id
,a.rec
,a.target
,a.seq
,a.map_intention
)
, agg_to_ret AS (
SELECT
srce
,target
,seq
,map_intention
,map_val
,retain_val
a.srce
,a.target
,a.seq
,a.map_intention
,a.map_val
,a.retain_val
,count(*) "count"
,jsonb_agg(rec) rec
FROM
agg_to_target
agg_to_target a
GROUP BY
srce
,target
,seq
,map_intention
,map_val
,retain_val
a.srce
,a.target
,a.seq
,a.map_intention
,a.map_val
,a.retain_val
)
, link_map AS (
@ -240,11 +239,13 @@ FROM
v.retval = a.map_val
)
SELECT
l.srce
,l.target
,l.map_val
,l."count"
,l.rec
l.srce srce
,l.target target
,l.map_val retval
,null::jsonb map
,null::jsonb hist
,l."count" cnt
,l.rec recs
FROM
link_map l
WHERE