reichlab / forecast-repository

Codebase for Zoltar forecast repository
https://zoltardata.com/
GNU General Public License v3.0
6 stars 3 forks source link

Change as_of forecast query semantics to handle partial forecast uploads #284

Closed matthewcornell closed 3 years ago

matthewcornell commented 3 years ago

Right now as_of operates at the at the forecast/timezero/issue_date level, not factoring in the unit/target level. This works OK with our current covidhub convention whereby forecast updates are done for all unit/target combinations. However, when we implement county-level truth forecasts, the files will be too large (~16MB) to upload with duplicates. Therefore we want to update/patch only "diffs". However, that will expose the weakness of the current as_of implementation. See the example at Zoltar as_of query examples.

A prerequisite to: [Think about representing truth as an oracle model #280].

matthewcornell commented 3 years ago

Results of today's meeting with @nickreich and @elray1 :

Updated examples: Zoltar as_of query examples

Results: 1a. in uploading a version (issue_date), users can mark a previous row as "deleted" by passing NULL for its value = Q: first cannot be NULL? = Q: other business rules?

1b. as_of will exclude NULL value rows from query results for any as_of >= that issue date

  1. when importing a forecast, rows with duplicate values are skipped. key: (fm.id, f.tz_id, pred.u_id, pred.tid, <sample/cat/value* columns>) = Q: class Meta constraint? = https://stackoverflow.com/questions/13947327/to-ignore-duplicate-keys-during-copy-from-in-postgresql = https://stackoverflow.com/questions/31639108/best-way-to-prevent-duplicate-data-on-copy-csv-postgresql = https://stackoverflow.com/questions/17267417/how-to-upsert-merge-insert-on-duplicate-update-in-postgresql = https://www.postgresql.org/message-id/CA%2BbJJbwjOgyy5%2BRFb%2BCVNntWFrwZKekG-qhcRy65HAA7FyLJJQ%40mail.gmail.com = https://dba.stackexchange.com/questions/30499/optimal-way-to-ignore-duplicate-inserts = https://dba.stackexchange.com/questions/13468/idiomatic-way-to-implement-upsert-in-postgresql