adjust column names outputed so they match destination table names
This commit is contained in:
parent
d2dbe2deb1
commit
83bea18a4c
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ node_modules/*
|
|||||||
*.log
|
*.log
|
||||||
*.pem
|
*.pem
|
||||||
.vscode/
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
DROP FUNCTION IF EXISTS tps.report_unmapped_recs;
|
DROP FUNCTION IF EXISTS tps.report_unmapped_recs;
|
||||||
CREATE FUNCTION tps.report_unmapped_recs(_srce text) RETURNS TABLE
|
CREATE FUNCTION tps.report_unmapped_recs(_srce text) RETURNS TABLE
|
||||||
(
|
(
|
||||||
source text,
|
srce text,
|
||||||
map text,
|
target text,
|
||||||
ret_val jsonb,
|
retval jsonb,
|
||||||
"count" bigint,
|
map jsonb,
|
||||||
|
hist jsonb,
|
||||||
|
cnt bigint,
|
||||||
recs jsonb
|
recs jsonb
|
||||||
|
|
||||||
)
|
)
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS
|
AS
|
||||||
@ -120,16 +121,16 @@ rx AS (
|
|||||||
|
|
||||||
, agg_to_target_items AS (
|
, agg_to_target_items AS (
|
||||||
SELECT
|
SELECT
|
||||||
srce
|
rx.srce
|
||||||
,id
|
,rx.id
|
||||||
,rec
|
,rx.rec
|
||||||
,target
|
,rx.target
|
||||||
,seq
|
,rx.seq
|
||||||
,map_intention
|
,rx.map_intention
|
||||||
,regex_function
|
,rx.regex_function
|
||||||
,target_item_number
|
,rx.target_item_number
|
||||||
,result_key_name
|
,rx.result_key_name
|
||||||
,target_json_path
|
,rx.target_json_path
|
||||||
,CASE WHEN map_key IS NULL
|
,CASE WHEN map_key IS NULL
|
||||||
THEN
|
THEN
|
||||||
NULL
|
NULL
|
||||||
@ -161,18 +162,18 @@ SELECT
|
|||||||
FROM
|
FROM
|
||||||
rx
|
rx
|
||||||
GROUP BY
|
GROUP BY
|
||||||
srce
|
rx.srce
|
||||||
,id
|
,rx.id
|
||||||
,rec
|
,rx.rec
|
||||||
,target
|
,rx.target
|
||||||
,seq
|
,rx.seq
|
||||||
,map_intention
|
,rx.map_intention
|
||||||
,regex_function
|
,rx.regex_function
|
||||||
,target_item_number
|
,rx.target_item_number
|
||||||
,result_key_name
|
,rx.result_key_name
|
||||||
,target_json_path
|
,rx.target_json_path
|
||||||
,map_key
|
,rx.map_key
|
||||||
,retain_key
|
,rx.retain_key
|
||||||
)
|
)
|
||||||
|
|
||||||
--SELECT * FROM agg_to_target_items LIMIT 100
|
--SELECT * FROM agg_to_target_items LIMIT 100
|
||||||
@ -180,45 +181,43 @@ GROUP BY
|
|||||||
|
|
||||||
, agg_to_target AS (
|
, agg_to_target AS (
|
||||||
SELECT
|
SELECT
|
||||||
srce
|
a.srce
|
||||||
,id
|
,a.id
|
||||||
,rec
|
,a.rec
|
||||||
,target
|
,a.target
|
||||||
,seq
|
,a.seq
|
||||||
,map_intention
|
,a.map_intention
|
||||||
,tps.jsonb_concat_obj(COALESCE(map_val,'{}'::JSONB)) map_val
|
,tps.jsonb_concat_obj(COALESCE(map_val,'{}'::JSONB)) map_val
|
||||||
,jsonb_strip_nulls(tps.jsonb_concat_obj(COALESCE(retain_val,'{}'::JSONB))) retain_val
|
,jsonb_strip_nulls(tps.jsonb_concat_obj(COALESCE(retain_val,'{}'::JSONB))) retain_val
|
||||||
FROM
|
FROM
|
||||||
agg_to_target_items
|
agg_to_target_items a
|
||||||
GROUP BY
|
GROUP BY
|
||||||
srce
|
a.srce
|
||||||
,id
|
,a.id
|
||||||
,rec
|
,a.rec
|
||||||
,target
|
,a.target
|
||||||
,seq
|
,a.seq
|
||||||
,map_intention
|
,a.map_intention
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
, agg_to_ret AS (
|
, agg_to_ret AS (
|
||||||
SELECT
|
SELECT
|
||||||
srce
|
a.srce
|
||||||
,target
|
,a.target
|
||||||
,seq
|
,a.seq
|
||||||
,map_intention
|
,a.map_intention
|
||||||
,map_val
|
,a.map_val
|
||||||
,retain_val
|
,a.retain_val
|
||||||
,count(*) "count"
|
,count(*) "count"
|
||||||
,jsonb_agg(rec) rec
|
,jsonb_agg(rec) rec
|
||||||
FROM
|
FROM
|
||||||
agg_to_target
|
agg_to_target a
|
||||||
GROUP BY
|
GROUP BY
|
||||||
srce
|
a.srce
|
||||||
,target
|
,a.target
|
||||||
,seq
|
,a.seq
|
||||||
,map_intention
|
,a.map_intention
|
||||||
,map_val
|
,a.map_val
|
||||||
,retain_val
|
,a.retain_val
|
||||||
)
|
)
|
||||||
|
|
||||||
, link_map AS (
|
, link_map AS (
|
||||||
@ -240,11 +239,13 @@ FROM
|
|||||||
v.retval = a.map_val
|
v.retval = a.map_val
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
l.srce
|
l.srce srce
|
||||||
,l.target
|
,l.target target
|
||||||
,l.map_val
|
,l.map_val retval
|
||||||
,l."count"
|
,null::jsonb map
|
||||||
,l.rec
|
,null::jsonb hist
|
||||||
|
,l."count" cnt
|
||||||
|
,l.rec recs
|
||||||
FROM
|
FROM
|
||||||
link_map l
|
link_map l
|
||||||
WHERE
|
WHERE
|
||||||
|
Loading…
Reference in New Issue
Block a user