merge summary of records not inserted from pt branch
This commit is contained in:
parent
4f958485d5
commit
748d6ddb3c
22
srce.pgsql
22
srce.pgsql
@ -89,8 +89,8 @@ WITH pending_list AS (
|
|||||||
----therefore, records may not be inserted due to ay matches with certain json fields, or if the entire json is a duplicate, reason is not specified
|
----therefore, records may not be inserted due to ay matches with certain json fields, or if the entire json is a duplicate, reason is not specified
|
||||||
RETURNING *
|
RETURNING *
|
||||||
)
|
)
|
||||||
|
---------raw list of records not inserted----------
|
||||||
----records not inserted------
|
, not_inserted AS (
|
||||||
SELECT
|
SELECT
|
||||||
srce
|
srce
|
||||||
,rec
|
,rec
|
||||||
@ -103,4 +103,20 @@ SELECT
|
|||||||
srce
|
srce
|
||||||
,rec
|
,rec
|
||||||
FROM
|
FROM
|
||||||
inserted;
|
inserted
|
||||||
|
)
|
||||||
|
--------summarize records not inserted------------------
|
||||||
|
SELECT
|
||||||
|
t.srce
|
||||||
|
,(ae.e::text[])[1] unq_constr
|
||||||
|
,MIN(rec #>> ae.e::text[]) min_text
|
||||||
|
,MAX(rec #>> ae.e::text[]) max_text
|
||||||
|
,JSONB_PRETTY(JSON_AGG(rec #> ae.e::text[] ORDER BY rec #>> ae.e::text[])::JSONB)
|
||||||
|
FROM
|
||||||
|
not_inserted t
|
||||||
|
INNER JOIN tps.srce s ON
|
||||||
|
s.srce = t.srce
|
||||||
|
LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS_TEXT(defn->'unique_constraint'->'fields') WITH ORDINALITY ae(e, rn) ON TRUE
|
||||||
|
GROUP BY
|
||||||
|
t.srce
|
||||||
|
,(ae.e::text[])[1];
|
Loading…
Reference in New Issue
Block a user