Nason commited on
Commit
bcf50c2
·
verified ·
1 Parent(s): 0e5aa14

Clarify dataset units, query setup and snapshot caveats

Browse files
Files changed (1) hide show
  1. README.md +19 -5
README.md CHANGED
@@ -26,6 +26,8 @@ Built with [fars-database](https://github.com/ian-nason/fars-database). Publishe
26
 
27
  ## Quick Start
28
 
 
 
29
  ### DuckDB CLI
30
 
31
  ```sql
@@ -44,7 +46,9 @@ GROUP BY state, statename
44
  ORDER BY fatalities DESC, state LIMIT 15;
45
  ```
46
 
47
- The database is 26 MB. DuckDB fetches byte ranges as needed; transfer volume depends on the query. The examples use this immutable artifact URL:
 
 
48
 
49
  ```
50
  https://huggingface.co/datasets/Nason/fars-database/resolve/adb6da02a314c39d8b6caf776529bf4a373075da/fars.duckdb
@@ -52,6 +56,8 @@ https://huggingface.co/datasets/Nason/fars-database/resolve/adb6da02a314c39d8b6c
52
 
53
  ### Python (duckdb)
54
 
 
 
55
  ```python
56
  import duckdb
57
  con = duckdb.connect(config={"memory_limit": "128MiB", "threads": "1", "max_temp_directory_size": "0B"})
@@ -62,7 +68,9 @@ con.sql("SELECT count(*) AS fatal_crashes, sum(fatals) AS fatalities FROM fars.c
62
  con.close()
63
  ```
64
 
65
- ### R (DBI + duckdb)
 
 
66
 
67
  ```r
68
  library(DBI)
@@ -79,13 +87,16 @@ In the tested R DuckDB 1.5.5 configuration, BIGINT and DECIMAL results are expos
79
 
80
  ### datapond package
81
 
82
- These examples use the public default catalog and the package's normal discovery and connection API:
 
 
83
 
84
  ```python
85
  import datapond
86
  print(datapond.list())
87
  datapond.describe('fars', table='person')
88
  con = datapond.connect('fars')
 
89
  con.sql('SELECT count(*) AS fatal_crashes, sum(fatals) AS fatalities FROM crashes').show()
90
  con.close()
91
  ```
@@ -94,6 +105,7 @@ con.close()
94
  library(datapond)
95
  dp_list()
96
  con <- dp_connect('fars')
 
97
  dp_describe(con, table = 'person')
98
  DBI::dbGetQuery(con, "SELECT count(*) AS fatal_crashes, sum(fatals) AS fatalities FROM crashes")
99
  dp_disconnect(con)
@@ -117,13 +129,15 @@ DBI::dbGetQuery(con, "SELECT count(*) AS fatal_crashes, sum(fatals) AS fatalitie
117
  dp_disconnect(con)
118
  ```
119
 
120
- Verify the recorded artifact SHA-256 after downloading. In tested Python 0.1.1, the optional Hugging Face download path follows the default branch rather than the pinned URL; see [consumer verification](https://github.com/ian-nason/fars-database/blob/main/docs/CONSUMERS.md) for the tested configuration.
121
 
122
  Default-catalog discovery and representative remote queries were verified after the registry merge. Earlier full-download checks used an isolated candidate registry. See [consumer verification](https://github.com/ian-nason/fars-database/blob/main/docs/CONSUMERS.md) for exact client versions, paths, resource limits and download behavior. The direct URL examples above work independently of the catalog. The SQL examples below use the `fars` catalog alias from the direct-URL quick start.
123
 
124
 
125
  ## Tables
126
 
 
 
127
  | Table | Description | Rows | Columns |
128
  |---|---|---:|---:|
129
  | `person` | One record per involved person, including nonoccupants and occupants of vehicles not in transport | 88,326 | 126 |
@@ -189,7 +203,7 @@ The full set is in [examples.sql](https://github.com/ian-nason/fars-database/blo
189
  5. **Imputed alcohol estimates are not here.** The three multiple-imputation files (`MIACC`, `MIDRVACC`, `MIPER`) are not loaded; this release cannot reproduce NHTSA's imputed impairment estimates. Per the [alcohol README](https://static.nhtsa.gov/nhtsa/downloads/FARS/README-BAC.pdf), such analyses compute an estimate in each of ten imputations and combine them.
190
  6. **Labels can conflict.** Four city codes carry more than one official label (state 4 code 428; 13/2190; 36/4170; 42/3950). `unambiguous_code_labels` omits them; never join `code_labels` on code alone. `mak_mod` is the combined make/model code; raw `model` is only meaningful with `make`.
191
  7. **Vintage and identity.** `st_case` identifies a crash within one year only; include year when pooling releases. The first ARF may be replaced by a final file with added or revised cases.
192
- 8. **Scope of this MVP.** Only `accident`, `vehicle` and `person` are loaded. Parkwork, multiple-response factors, drug/race, vPIC decode and auxiliary files are omitted; their archived identities are pinned in the source lock.
193
 
194
  ## Data Source and Version
195
 
 
26
 
27
  ## Quick Start
28
 
29
+ Choose one route: the [datapond package](#datapond-package) finds the database by catalog ID; the direct [Python](#python-duckdb), [R](#r-with-dbi-and-duckdb) and SQL examples use a fixed artifact URL. These are alternatives, not steps that must all be run. The SQL block requires a DuckDB SQL client.
30
+
31
  ### DuckDB CLI
32
 
33
  ```sql
 
46
  ORDER BY fatalities DESC, state LIMIT 15;
47
  ```
48
 
49
+ The database file is 25.3 MiB. DuckDB fetches byte ranges as needed; transfer volume depends on the query. File size is disk storage, not a RAM estimate. Remote queries still run on your machine and can transfer much of the file. A filter or `LIMIT` after a join or aggregate does not guarantee a small scan. The 128 MiB setting limits DuckDB's buffer pool, not the whole Python/R process; with spill disabled, a larger query can fail at that limit. Download only if you have room for the file, temporary download bytes and any existing copy.
50
+
51
+ The examples use this immutable artifact URL:
52
 
53
  ```
54
  https://huggingface.co/datasets/Nason/fars-database/resolve/adb6da02a314c39d8b6caf776529bf4a373075da/fars.duckdb
 
56
 
57
  ### Python (duckdb)
58
 
59
+ Install the Python dependency once in the environment that runs your query: `python -m pip install duckdb`.
60
+
61
  ```python
62
  import duckdb
63
  con = duckdb.connect(config={"memory_limit": "128MiB", "threads": "1", "max_temp_directory_size": "0B"})
 
68
  con.close()
69
  ```
70
 
71
+ ### R with DBI and duckdb
72
+
73
+ Install the R dependencies once: `install.packages(c("DBI", "duckdb"))`.
74
 
75
  ```r
76
  library(DBI)
 
87
 
88
  ### datapond package
89
 
90
+ Install or upgrade the Python client with `python -m pip install --upgrade datapond`, or install the released R client from [CRAN](https://cran.r-project.org/package=datapond) with `install.packages("datapond")`. Remote examples are tested with Python datapond 0.1.5 (DuckDB 1.5.4) and CRAN R datapond 0.1.0 (DuckDB 1.5.5); older DuckDB reader versions are not verified here. R 0.1.1 is a separate development version, not the CRAN release.
91
+
92
+ The examples below use the public default catalog. For limits set before attachment, use the direct DuckDB examples above; package examples here set limits immediately after connecting:
93
 
94
  ```python
95
  import datapond
96
  print(datapond.list())
97
  datapond.describe('fars', table='person')
98
  con = datapond.connect('fars')
99
+ con.execute("SET memory_limit='128MiB'; SET threads=1; SET max_temp_directory_size='0B'")
100
  con.sql('SELECT count(*) AS fatal_crashes, sum(fatals) AS fatalities FROM crashes').show()
101
  con.close()
102
  ```
 
105
  library(datapond)
106
  dp_list()
107
  con <- dp_connect('fars')
108
+ DBI::dbExecute(con, "SET memory_limit='128MiB'; SET threads=1; SET max_temp_directory_size='0B'")
109
  dp_describe(con, table = 'person')
110
  DBI::dbGetQuery(con, "SELECT count(*) AS fatal_crashes, sum(fatals) AS fatalities FROM crashes")
111
  dp_disconnect(con)
 
129
  dp_disconnect(con)
130
  ```
131
 
132
+ Verify the recorded artifact SHA-256 after downloading. In Python datapond 0.1.5 as well as 0.1.1, the optional `huggingface_hub` download path follows the repository default branch rather than the pinned URL. For an exact-version copy, download the immutable URL shown above and verify its checksum; see [consumer verification](https://github.com/ian-nason/fars-database/blob/main/docs/CONSUMERS.md) for the tested configuration.
133
 
134
  Default-catalog discovery and representative remote queries were verified after the registry merge. Earlier full-download checks used an isolated candidate registry. See [consumer verification](https://github.com/ian-nason/fars-database/blob/main/docs/CONSUMERS.md) for exact client versions, paths, resource limits and download behavior. The direct URL examples above work independently of the catalog. The SQL examples below use the `fars` catalog alias from the direct-URL quick start.
135
 
136
 
137
  ## Tables
138
 
139
+ Choose the unit before querying: the `crashes` view over `accident` has one row per fatal crash; `vehicle` has one row per vehicle in transport; and the `people` view over `person` has one row per recorded person. A crash can have several vehicles and people; use `crashes` for crash totals.
140
+
141
  | Table | Description | Rows | Columns |
142
  |---|---|---:|---:|
143
  | `person` | One record per involved person, including nonoccupants and occupants of vehicles not in transport | 88,326 | 126 |
 
203
  5. **Imputed alcohol estimates are not here.** The three multiple-imputation files (`MIACC`, `MIDRVACC`, `MIPER`) are not loaded; this release cannot reproduce NHTSA's imputed impairment estimates. Per the [alcohol README](https://static.nhtsa.gov/nhtsa/downloads/FARS/README-BAC.pdf), such analyses compute an estimate in each of ten imputations and combine them.
204
  6. **Labels can conflict.** Four city codes carry more than one official label (state 4 code 428; 13/2190; 36/4170; 42/3950). `unambiguous_code_labels` omits them; never join `code_labels` on code alone. `mak_mod` is the combined make/model code; raw `model` is only meaningful with `make`.
205
  7. **Vintage and identity.** `st_case` identifies a crash within one year only; include year when pooling releases. The first ARF may be replaced by a final file with added or revised cases.
206
+ 8. **Scope of this release.** Only `accident`, `vehicle` and `person` are loaded. Parkwork, multiple-response factors, drug/race, vPIC decode and auxiliary files are omitted; their archived identities are pinned in the source lock.
207
 
208
  ## Data Source and Version
209