Project

General

Profile

6. left-join tables

from Left-joining a datasource > prevent column collisions by prepending the table name to each column name

  1. add subdir:
    make inputs/$datasrc/'taxon_observation.**'/add
    "cp" -f inputs/VegBank/'taxon_observation.**'/{run,postprocess.sql} inputs/$dest/'taxon_observation.**'/ # add new-style import files
    echo 'taxon_observation.**' >>inputs/$datasrc/import_order.txt
    
  2. edit postprocess.sql:
    1. change the table names to those of the datasource
    2. set the sort_col (the first column in the view) to be a joined table's pkey
  3. install the view:
    inputs/$datasrc/'taxon_observation.**'/run
    # fix bugs and repeat until it has a successful exit status
    
  4. 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 -e Source -e 'taxon_observation.**' inputs/$datasrc/import_order.txt); do
        "cp" -f inputs/FIA/COND/_no_import inputs/$datasrc/$table/
    done