From 7eba5981ef5a119164a0aa1905d380bc074b5d04 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 26 Oct 2017 17:34:21 -0400 Subject: [PATCH] trim retained values --- do_map_g_option.pgsql | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/do_map_g_option.pgsql b/do_map_g_option.pgsql index b4c3a74..31ddc3b 100644 --- a/do_map_g_option.pgsql +++ b/do_map_g_option.pgsql @@ -1,4 +1,4 @@ - +\timing WITH --------------------apply regex operations to transactions----------------------------------------------------------------------------------- @@ -53,11 +53,11 @@ SELECT CASE regex->>'function' WHEN 'extract' THEN CASE WHEN array_upper(mt.mt,1)=1 - THEN to_json(mt.mt[1]) + THEN to_json(trim(mt.mt[1])) ELSE array_to_json(mt.mt) END::jsonb WHEN 'replace' THEN - to_jsonb(rp.rp) + to_jsonb(rtrim(rp.rp)) ELSE '{}'::jsonb END @@ -76,7 +76,8 @@ FROM LEFT JOIN LATERAL regexp_replace(t.rec #>> ((e.v ->> 'key')::text[]), e.v ->> 'regex'::text, e.v ->> 'replace'::text,e.v ->> 'flag') WITH ORDINALITY rp(rp, rn) ON m.regex->>'function' = 'replace' WHERE - t.srce = 'PNCC' + --t.srce = 'PNCC' + rec @> '{"Transaction":"ACH Credits","Transaction":"ACH Debits"}' --rec @> '{"Description":"CHECK 93013270 086129935"}'::jsonb ORDER BY t.id DESC, @@ -197,9 +198,9 @@ GROUP BY ,id ) ---SELECT * FROM agg_to_id - +SELECT srce, id, jsonb_pretty(retain_val), jsonb_pretty(map) FROM agg_to_id +/* UPDATE tps.trans t SET @@ -209,4 +210,5 @@ SET FROM agg_to_id o WHERE - o.id = t.id; \ No newline at end of file + o.id = t.id; +*/ \ No newline at end of file