get rid of commented json sample, swap for pt branch files

This commit is contained in:
Paul Trowbridge 2017-10-13 02:40:23 -04:00
parent acc0ce0613
commit 1a5aa39651

View File

@ -1,47 +1,3 @@
/*
SELECT
jsonb_pretty(
$$
{
"name": "GOOGDM",
"type": "json_csv",
"schema": {
"rows": [
{
"elements": [
{
"status": "text",
"distance": {
"text": "text",
"value": "numeric"
},
"duration": {
"text": "text",
"value": "value"
}
}
]
}
],
"status": "text",
"origin_addresses": [
"text"
],
"destination_addresses": [
"text"
]
},
"unique_constraint": {
"type": "key",
"fields": [
"{origin_adresses,0}",
"{destination_adresses,0}"
]
}
}
$$::jsonb
)
*/
DO $$ DO $$
@ -59,13 +15,15 @@ begin
TPS.srce TPS.srce
--unwrap the schema definition array --unwrap the schema definition array
LEFT JOIN LATERAL jsonb_populate_recordset(null::tps.srce_defn_schema, defn->'schema') prs ON TRUE LEFT JOIN LATERAL jsonb_populate_recordset(null::tps.srce_defn_schema, defn->'schema') prs ON TRUE
WHERE
srce = 'DCARD'
GROUP BY GROUP BY
srce; srce;
----------------------------------------------------add create table verbage in front of column list-------------------------------------------------------- ----------------------------------------------------add create table verbage in front of column list--------------------------------------------------------
_t := format('CREATE TEMP TABLE csv_i (%s)', _t); _t := format('CREATE TEMP TABLE csv_i (%s)', _t);
--raise notice '%', _t; raise notice '%', _t;
----------------------------------------------------build the table----------------------------------------------------------------------------------------- ----------------------------------------------------build the table-----------------------------------------------------------------------------------------
@ -74,7 +32,19 @@ begin
EXECUTE _t; EXECUTE _t;
COPY csv_i FROM 'C:\Users\fleet\downloads\dc.csv' WITH (HEADER TRUE,DELIMITER ',', FORMAT CSV, ENCODING 'SQL_ASCII',QUOTE '"');
end end
$$; $$;
SELECT * FROM csv_i; SELECT * FROM csv_i;
/*
INSERT INTO
tps.trans (srce, rec)
SELECT
'DCARD', row_to_json(csv_i) FROM csv_i;
*/