implement retain flag to drop keys used only for linking to the appropriate map value, but not acutally included in the map
This commit is contained in:
parent
9001c44b46
commit
ccd685ca22
@ -19,7 +19,8 @@ SELECT
|
||||
ELSE array_to_json(mt.mt)
|
||||
END
|
||||
) retval,
|
||||
m.seq
|
||||
m.seq,
|
||||
e.v->>'retain' retain
|
||||
FROM
|
||||
tps.map_rm m
|
||||
LEFT JOIN LATERAL jsonb_array_elements(m.regex->'where') w(v) ON TRUE
|
||||
@ -48,6 +49,7 @@ agg_rx AS (
|
||||
rx.id,
|
||||
tps.jsonb_concat_obj(rx.rkey) rkey,
|
||||
tps.jsonb_concat_obj(rx.retval) AS retval,
|
||||
tps.jsonb_concat_obj(CASE rx.retain WHEN 'y' THEN rx.retval ELSE '{}'::jsonb END) retain,
|
||||
rx.seq
|
||||
FROM
|
||||
--unwrap json instruction and apply regex using a count per original line for re-aggregation
|
||||
@ -63,13 +65,13 @@ agg_rx AS (
|
||||
|
||||
-------------aggregate all targets back to row level (id)------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SELECT
|
||||
u.srce,
|
||||
u.id,
|
||||
string_agg(u.target,',') target,
|
||||
jsonb_pretty(tps.jsonb_concat_obj(coalesce(v.map,'{}'::jsonb) ORDER BY seq )) map,
|
||||
jsonb_pretty(tps.jsonb_concat_obj(u.retval||coalesce(v.map,'{}'::jsonb) ORDER BY seq)) comb
|
||||
jsonb_pretty(tps.jsonb_concat_obj(u.retval||coalesce(v.map,'{}'::jsonb) ORDER BY seq)) comb,
|
||||
jsonb_pretty(tps.jsonb_concat_obj(u.retain||coalesce(v.map,'{}'::jsonb) ORDER BY seq)) retain
|
||||
FROM
|
||||
--re-aggregate return values and explude any records where one or more regex failed with a null result
|
||||
agg_rx u
|
||||
|
Loading…
Reference in New Issue
Block a user