From e694991d9073aa8e0b43c11b19e23f18fdac2a1c Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 24 May 2018 17:31:17 -0400 Subject: [PATCH] function was implemented elsewhere delete --- ideas/sql_from_srce_definition.sql | 52 ------------------------------ 1 file changed, 52 deletions(-) delete mode 100644 ideas/sql_from_srce_definition.sql diff --git a/ideas/sql_from_srce_definition.sql b/ideas/sql_from_srce_definition.sql deleted file mode 100644 index cfe8cd3..0000000 --- a/ideas/sql_from_srce_definition.sql +++ /dev/null @@ -1,52 +0,0 @@ -WITH s AS ( -select -$${ - "name":"DMAPI", - "source":"client_file", - "loading_function":"csv", - "constraint":[ - "{doc}" - ], - "schema_type":"JSONB_POPULATE", - "table_schema":[ - { - "path":"{doc,origin_addresses,0}", - "type":"text", - "column_name":"origin_address" - }, - { - "path":"{doc,destination_addresses,0}", - "type":"text", - "column_name":"origin_address" - }, - { - "path":"{doc,status}", - "type":"text", - "column_name":"status" - }, - { - "path":"{doc,rows,0,elements,0,distance,value}", - "type":"numeric", - "column_name":"distance" - }, - { - "path":"{doc,rows,0,elements,0,duration,value}", - "type":"numeric", - "column_name":"duration" - } - ] -}$$::jsonb->'table_schema' defn -) -,ext AS ( -SELECT - ae.v->>'path' path - ,ae.v->>'type' dtype - ,ae.v->>'column_name' column_name -FROM - s - LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS(s.defn) ae(v) ON TRUE -) -SELECT - 'SELECT '||string_agg('(rec#>>('''||path||'''::text[]))::'||dtype||' AS '||column_name,', ')||' FROM tps.trans WHERE srce = ''DMAPI''' -FROM - ext \ No newline at end of file