add link to tps trans to find any potential import conflicts
This commit is contained in:
parent
668ca9f44a
commit
ac4d9f68d5
19
srce.pgsql
19
srce.pgsql
@ -49,12 +49,14 @@ $$;
|
||||
--*******************************************
|
||||
--this needs to aggregate on id sequence
|
||||
--*******************************************
|
||||
WITH pending_list AS (
|
||||
SELECT
|
||||
---creates a key value pair and then aggregates rows of key value pairs
|
||||
jsonb_object_agg(
|
||||
(ae.e::text[])[1], --the key name
|
||||
(row_to_json(i)::jsonb) #> ae.e::text[] --get the target value from the key from the csv row that has been converted to json
|
||||
) json_key,
|
||||
row_to_json(i) rec,
|
||||
srce,
|
||||
--ae.rn,
|
||||
id
|
||||
@ -64,7 +66,22 @@ FROM
|
||||
s.srce = 'DCARD'
|
||||
LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS_TEXT(defn->'unique_constraint'->'fields') WITH ORDINALITY ae(e, rn) ON TRUE
|
||||
GROUP BY
|
||||
i.*,
|
||||
srce,
|
||||
id
|
||||
ORDER BY
|
||||
id
|
||||
id
|
||||
)
|
||||
, matched_tps AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
pending_list pl
|
||||
INNER JOIN tps.trans t ON
|
||||
t.srce = pl.srce
|
||||
AND t.rec @> pl.json_key
|
||||
)
|
||||
SELECT * FROM matched_tps;
|
||||
|
||||
-- need to compare against and tps matches
|
||||
-- therefore need to apply keyset to tps rows
|
Loading…
Reference in New Issue
Block a user