get rid of clone files; move mapping to readme; rename setup to sequence the operations
This commit is contained in:
parent
d0a4f8324d
commit
8bda52f770
34
readme.md
34
readme.md
@ -10,6 +10,40 @@ setup
|
|||||||
* `PGD -f setup_sql/build_maste_tables.sql` to create master data tables from forecast data
|
* `PGD -f setup_sql/build_maste_tables.sql` to create master data tables from forecast data
|
||||||
* `./routes/baseline/generate_route_sql.sh` to create the baseline sql used by the /baseline route
|
* `./routes/baseline/generate_route_sql.sh` to create the baseline sql used by the /baseline route
|
||||||
|
|
||||||
|
| schema | tname | cname | opos | func | fkey | fcol | dtype | appcol | pretty |
|
||||||
|
| ------- | ------- | -------------- | ---- | ------------ | ------------ | -------------- | ------- | ------------ | ------ |
|
||||||
|
| fc | live | fb_cst_loc | 91 | cost | | fb_cst_loc | numeric | | |
|
||||||
|
| fc | live | ship_cust | 36 | scust | scust | ship_cust | text | | |
|
||||||
|
| fc | live | rdate | 98 | rdate | rdate | drange | date | | |
|
||||||
|
| fc | live | geo | 42 | scust | | geo | text | customer | |
|
||||||
|
| fc | live | part | 54 | item | item | part | text | item | |
|
||||||
|
| fc | live | odate | 96 | odate | odate | drange | date | order_date | |
|
||||||
|
| fc | live | sdate | 100 | sdate | sdate | sdate | date | ship_date | |
|
||||||
|
| fc | live | oseas | 97 | odate | | ssyr | integer | | |
|
||||||
|
| fc | live | calc_status | 94 | order_status | order_status | calc_status | text | order_status | |
|
||||||
|
| fc | live | rseas | 99 | rdate | | ssyr | integer | | |
|
||||||
|
| fc | live | sseas | 101 | sdate | | ssyr | integer | | |
|
||||||
|
| | | | | | | | | version | |
|
||||||
|
| | | | | | | | | iter | |
|
||||||
|
| | | | | | | | | logid | |
|
||||||
|
|
||||||
|
* func: table name of associated data
|
||||||
|
* fkey: primary key of assoicated dat
|
||||||
|
* fcol: associated field from the master data table if it is different (oseas would refer to ssyr in fc.perd)
|
||||||
|
* pretty: display column name (user friendly)
|
||||||
|
* appcol: parameters that will have to be supplied but the application
|
||||||
|
* order_date
|
||||||
|
* ship_date
|
||||||
|
* customer
|
||||||
|
* item
|
||||||
|
* order_stats
|
||||||
|
* units
|
||||||
|
* cost
|
||||||
|
* value
|
||||||
|
* version (added if missing)
|
||||||
|
* iter (added if missing)
|
||||||
|
* logid (added if missing)
|
||||||
|
|
||||||
routes
|
routes
|
||||||
----------------------------------------------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
* all routes would be tied to an underlying sql that builds the incremental rows
|
* all routes would be tied to an underlying sql that builds the incremental rows
|
||||||
|
@ -1,111 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS fc.live AS (
|
|
||||||
SELECT
|
|
||||||
o."ddord#"
|
|
||||||
,o."dditm#"
|
|
||||||
,o."fgbol#"
|
|
||||||
,o."fgent#"
|
|
||||||
,o."diinv#"
|
|
||||||
,o."dilin#"
|
|
||||||
,o.quoten
|
|
||||||
,o.quotel
|
|
||||||
,o.dcodat
|
|
||||||
,o.ddqdat
|
|
||||||
,o.dcmdat
|
|
||||||
,o.fesdat
|
|
||||||
,o.dhidat
|
|
||||||
,o.fesind
|
|
||||||
,o.dhpost
|
|
||||||
,o.fspr
|
|
||||||
,o.ddqtoi
|
|
||||||
,o.ddqtsi
|
|
||||||
,o.fgqshp
|
|
||||||
,o.diqtsh
|
|
||||||
,o.diext
|
|
||||||
,o.ditdis
|
|
||||||
,o.discj
|
|
||||||
,o.dhincr
|
|
||||||
,o.plnt
|
|
||||||
,o.promo
|
|
||||||
,o.return_reas
|
|
||||||
,o.terms
|
|
||||||
,o.custpo
|
|
||||||
,o.remit_to
|
|
||||||
,o.bill_class
|
|
||||||
,o.bill_cust
|
|
||||||
,o.bill_rep
|
|
||||||
,o.bill_terr
|
|
||||||
,o.ship_class
|
|
||||||
,o.ship_cust
|
|
||||||
,o.ship_rep
|
|
||||||
,o.ship_terr
|
|
||||||
,o.dsm
|
|
||||||
,o.account
|
|
||||||
,o.shipgrp
|
|
||||||
,o.geo
|
|
||||||
,o.chan
|
|
||||||
,o.chansub
|
|
||||||
,o.orig_ctry
|
|
||||||
,o.orig_prov
|
|
||||||
,o.orig_post
|
|
||||||
,o.bill_ctry
|
|
||||||
,o.bill_prov
|
|
||||||
,o.bill_post
|
|
||||||
,o.dest_ctry
|
|
||||||
,o.dest_prov
|
|
||||||
,o.dest_post
|
|
||||||
,o.part
|
|
||||||
,o.styc
|
|
||||||
,o.colc
|
|
||||||
,o.colgrp
|
|
||||||
,o.coltier
|
|
||||||
,o.colstat
|
|
||||||
,o.sizc
|
|
||||||
,o.pckg
|
|
||||||
,o.kit
|
|
||||||
,o.brnd
|
|
||||||
,o.majg
|
|
||||||
,o.ming
|
|
||||||
,o.majs
|
|
||||||
,o.mins
|
|
||||||
,o.gldco
|
|
||||||
,o.gldc
|
|
||||||
,o.glec
|
|
||||||
,o.harm
|
|
||||||
,o.clss
|
|
||||||
,o.brand
|
|
||||||
,o.assc
|
|
||||||
,o.ddunit
|
|
||||||
,o.unti
|
|
||||||
,o.lbs
|
|
||||||
,o.plt
|
|
||||||
,o.plcd
|
|
||||||
,o.fs_line
|
|
||||||
,o.r_currency
|
|
||||||
,o.r_rate
|
|
||||||
,o.c_currency
|
|
||||||
,o.c_rate
|
|
||||||
,o.fb_qty
|
|
||||||
,o.fb_val_loc
|
|
||||||
,o.fb_val_loc_dis
|
|
||||||
,o.fb_val_loc_qt
|
|
||||||
,o.fb_val_loc_pl
|
|
||||||
,o.fb_val_loc_tar
|
|
||||||
,o.fb_cst_loc
|
|
||||||
,o.fb_cst_loc_cur
|
|
||||||
,o.fb_cst_loc_fut
|
|
||||||
,o.calc_status
|
|
||||||
,o.flag
|
|
||||||
,o.odate
|
|
||||||
,o.oseas
|
|
||||||
,o.rdate
|
|
||||||
,o.rseas
|
|
||||||
,o.sdate
|
|
||||||
,o.sseas
|
|
||||||
,o.version
|
|
||||||
,o.iter
|
|
||||||
,null::text AS _comment
|
|
||||||
,null::integer AS _logid
|
|
||||||
,null::text AS _tag
|
|
||||||
FROM
|
|
||||||
rlarp.osm_dev o
|
|
||||||
) WITH DATA;
|
|
@ -1,31 +0,0 @@
|
|||||||
BEGIN;
|
|
||||||
INSERT INTO
|
|
||||||
fc.target_meta
|
|
||||||
SELECT
|
|
||||||
--hard-coded name of new clone table
|
|
||||||
'fc.live' tname
|
|
||||||
,cname
|
|
||||||
,opos
|
|
||||||
,func
|
|
||||||
,fkey
|
|
||||||
,pretty
|
|
||||||
,dtype
|
|
||||||
,mastcol
|
|
||||||
,appcol
|
|
||||||
,dateref
|
|
||||||
FROM
|
|
||||||
fc.target_meta
|
|
||||||
WHERE
|
|
||||||
--hard-coded original sales data with mapped fields
|
|
||||||
tname = 'rlarp.osm_dev'
|
|
||||||
ON CONFLICT ON CONSTRAINT target_meta_pk DO UPDATE SET
|
|
||||||
func = EXCLUDED.func
|
|
||||||
,pretty = EXCLUDED.pretty
|
|
||||||
,mastcol = EXCLUDED.mastcol
|
|
||||||
,appcol = EXCLUDED.appcol
|
|
||||||
,dateref = EXCLUDED.dateref
|
|
||||||
,fkey = EXCLUDED.fkey;
|
|
||||||
--SELECT * FROM fc.target_meta WHERE tname = 'fc.live';
|
|
||||||
--ROLLBACK;
|
|
||||||
COMMIT;
|
|
||||||
END;
|
|
@ -1,49 +0,0 @@
|
|||||||
DO
|
|
||||||
$func$
|
|
||||||
DECLARE
|
|
||||||
_clist text;
|
|
||||||
_targ text;
|
|
||||||
_sql text;
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
-----------------------------this target would be replaced with a parameter--------------
|
|
||||||
SELECT
|
|
||||||
'rlarp.osm_dev o'
|
|
||||||
INTO
|
|
||||||
_targ;
|
|
||||||
|
|
||||||
-------------------------------build a column list-----------------------------------------
|
|
||||||
-----------a list of required columns is in fc.appcols, if they are not present------------
|
|
||||||
-----------they will have to build included------------------------------------------------
|
|
||||||
SELECT
|
|
||||||
string_agg(
|
|
||||||
--if the colum name is empty that means we are dealig with a required appcol
|
|
||||||
--that isn't present: use the appcol.col for the name preceded by underscore
|
|
||||||
CASE WHEN m.cname IS NULL
|
|
||||||
THEN COALESCE(a.dflt,'null::'||a.dtype)||' AS _'||a.col
|
|
||||||
ELSE 'o.'||format('%I',COALESCE(cname,''))
|
|
||||||
END
|
|
||||||
,E'\n ,' ORDER BY opos ASC)
|
|
||||||
INTO
|
|
||||||
_clist
|
|
||||||
FROM
|
|
||||||
fc.target_meta m
|
|
||||||
FULL OUTER JOIN fc.appcols a ON
|
|
||||||
m.appcol = a.col
|
|
||||||
AND m.dtype = a.dtype
|
|
||||||
WHERE
|
|
||||||
tname = _targ;
|
|
||||||
|
|
||||||
_sql:= $$CREATE TABLE IF NOT EXISTS fc.live AS (
|
|
||||||
SELECT
|
|
||||||
$$||_clist||$$
|
|
||||||
FROM
|
|
||||||
$$||_targ||$$
|
|
||||||
) WITH DATA;$$;
|
|
||||||
|
|
||||||
--RAISE NOTICE '%', _sql;
|
|
||||||
|
|
||||||
INSERT INTO fc.sql SELECT 'live', _sql ON CONFLICT ON CONSTRAINT sql_pkey DO UPDATE SET t = EXCLUDED.t;
|
|
||||||
|
|
||||||
END;
|
|
||||||
$func$
|
|
@ -1,4 +0,0 @@
|
|||||||
# execure the sql for scale which builds the sql and inserts into a table
|
|
||||||
$PGD -f gen_clone.sql
|
|
||||||
# pull the sql out of the table and write it to route directory
|
|
||||||
$PGD -c "SELECT t FROM fc.sql WHERE cmd = 'clone'" -t -A -o clone.sql
|
|
@ -1,34 +0,0 @@
|
|||||||
| schema | tname | cname | opos | func | fkey | fcol | dtype | appcol | pretty |
|
|
||||||
| ------- | ------- | -------------- | ---- | ------------ | ------------ | -------------- | ------- | ------------ | ------ |
|
|
||||||
| fc | live | fb_cst_loc | 91 | cost | | fb_cst_loc | numeric | | |
|
|
||||||
| fc | live | ship_cust | 36 | scust | scust | ship_cust | text | | |
|
|
||||||
| fc | live | rdate | 98 | rdate | rdate | drange | date | | |
|
|
||||||
| fc | live | geo | 42 | scust | | geo | text | customer | |
|
|
||||||
| fc | live | part | 54 | item | item | part | text | item | |
|
|
||||||
| fc | live | odate | 96 | odate | odate | drange | date | order_date | |
|
|
||||||
| fc | live | sdate | 100 | sdate | sdate | sdate | date | ship_date | |
|
|
||||||
| fc | live | oseas | 97 | odate | | ssyr | integer | | |
|
|
||||||
| fc | live | calc_status | 94 | order_status | order_status | calc_status | text | order_status | |
|
|
||||||
| fc | live | rseas | 99 | rdate | | ssyr | integer | | |
|
|
||||||
| fc | live | sseas | 101 | sdate | | ssyr | integer | | |
|
|
||||||
| | | | | | | | | version | |
|
|
||||||
| | | | | | | | | iter | |
|
|
||||||
| | | | | | | | | logid | |
|
|
||||||
|
|
||||||
* func: table name of associated data
|
|
||||||
* fkey: primary key of assoicated dat
|
|
||||||
* fcol: associated field from the master data table if it is different (oseas would refer to ssyr in fc.perd)
|
|
||||||
* pretty: display column name (user friendly)
|
|
||||||
* appcol: parameters that will have to be supplied but the application
|
|
||||||
* order_date
|
|
||||||
* ship_date
|
|
||||||
* customer
|
|
||||||
* item
|
|
||||||
* order_stats
|
|
||||||
* units
|
|
||||||
* cost
|
|
||||||
* value
|
|
||||||
* version (added if missing)
|
|
||||||
* iter (added if missing)
|
|
||||||
* logid (added if missing)
|
|
||||||
* dateref:
|
|
Loading…
Reference in New Issue
Block a user