Denormalizing a datasource¶
38% complete: 3 of 8 datasources switched
to switch: CVS, FIA, Madidi, (NVS), SALVIAS, TEAM, VegBank, (newWorld)
- do staging table column renaming
- prevent column collisions by prepending the table name to each column name
- in each
map.csv
:- replace text
,*
with text,*table--
- replace text
inputs/$dest/run postprocess # runtime: 1-2 min
- commit:
svn st inputs/$dest/*/test.xml.ref # make sure there are no changes svn di svn ci -m 'inputs/$dest/: prepended the table name to each column name to prevent column collisions, using the steps at http://vegbiendev.nceas.ucsb.edu/wiki/Left-joining_a_datasource'
- on vegbiendev:
svn up inputs/$dest/run postprocess # runtime: 4-6 min
- in each
- add flattened view
- add subdir:
make inputs/$dest/'taxon_observation.**'/add "cp" -f inputs/FIA/'taxon_observation.**'/{run,postprocess.sql} inputs/$dest/'taxon_observation.**'/ echo 'taxon_observation.**' >>inputs/$dest/import_order.txt
- edit
postprocess.sql
:- change the table names to those of the datasource
- set the first column in the view to be the
row_num
(if one exists) orsort_col
(which should be a joined table's pkey) - if using a
sort_col
, remove the'row_num'
argument tomk_subset_by_row_num_func()
inputs/$dest/'taxon_observation.**'/run
- fix bugs and repeat until it has a successful exit status
make inputs/$dest/add
- commit:
svn di svn ci -m 'inputs/$dest/: added taxon_observation.** left-join of the tables, using the steps at http://vegbiendev.nceas.ucsb.edu/wiki/Left-joining_a_datasource'
- on vegbiendev:
svn up inputs/$dest/'taxon_observation.**'/run
- add subdir:
- prevent joined tables from also being imported (after the left-join above is successful)
- create a blank file named
_no_import
in each table subdir:for table in $(grep -vF Source inputs/$dest/import_order.txt); do "cp" -f inputs/FIA/COND/_no_import inputs/$dest/$table/; done make inputs/$dest/add
- commit:
svn st svn ci -m 'inputs/CVS/: don'\''t import joined tables, because they are now imported in the taxon_observation.** left-join instead'
- on vegbiendev:
svn up inputs/$dest/run # runtime: 4-6 min
- create a blank file named