Skip to content

Commit

Permalink
Remove duckdb #11
Browse files Browse the repository at this point in the history
  • Loading branch information
JackKelly committed Sep 12, 2024
1 parent de91775 commit d1eeb91
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 58 deletions.
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ readme = "README.md"
authors=["Jack Kelly <[email protected]>"]

[workspace.dependencies] # In alphabetical order
anyhow = "1.0.86"
anyhow = "1.0.88"
bytes = "1.7.1"
clap = "4.5.16" # parse command line arguments etc.
clap = "4.5.17" # parse command line arguments etc.
csv = "1.3.0"
duckdb = "1.0.0"
futures-util = "0.3.30"
gribberish = "0.20.1"
gribberish = "0.20.2"
indicatif = "0.17.8" # progress bars etc.
object_store = "0.11.0"
serde = "1.0.209"
serde = "1.0.210"
tokio = { version = "1.40.0", features = ["rt-multi-thread"]}
url = "2.5.2"

Expand Down
1 change: 0 additions & 1 deletion crates/hypergrib_manifest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ anyhow.workspace = true
bytes.workspace = true
clap = { workspace = true, features = ["derive"] }
csv.workspace = true
duckdb = { workspace = true, features = ["bundled"] }
futures-util.workspace = true
gribberish.workspace = true
indicatif.workspace = true
Expand Down
52 changes: 0 additions & 52 deletions crates/hypergrib_manifest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,6 @@ fn parse_idx(b: &[u8]) -> anyhow::Result<Vec<IdxRecord>> {
Ok(records)
}

fn read_idx_into_duck_db(filename: String) -> anyhow::Result<()> {
let conn = duckdb::Connection::open_in_memory()?;

conn.execute_batch(
r"CREATE TABLE grib_message (
msg_id INTEGER,
byte_offset INTEGER,
init_time TIMESTAMP,
nwp_variable VARCHAR,
vertical_level VARCHAR,
step_raw VARCHAR,
step INTERVAL,
ens_member VARCHAR,
);
",
)?;
// TODO: Change to enums: nwp_variable, vertical_level, ensemble_member
// TODO: Add filename of GRIB file (with full path)

conn.execute_batch(
r"COPY grib_message (msg_id, byte_offset, init_time, nwp_variable, vertical_level, step_raw, ens_member) FROM
'/home/jack/dev/rust/hypergrib/gec00.t00z.pgrb2af000.idx'
(
DELIMITER ':',
FORMAT CSV,
HEADER false,
AUTO_DETECT false,
TIMESTAMPFORMAT 'd=%Y%m%d%H'
);
",
)?;
// TODO: Pass in filename argument!
// TODO: Convert step_raw to step, maybe by first storing step_raw as VARCHAR, replacing 'anl'
// with '0', taking just the first two characters of the string, converting that to an int, and
// passing that to [`to_hours(integer)`](https://duckdb.org/docs/sql/functions/interval#to_hoursinteger)

// Print some test data:
let mut stmt = conn.prepare("SELECT * FROM grib_message WHERE msg_id < 5")?;
let mut rows = stmt.query([])?;
while let Some(row) = rows.next()? {
println!("{:?}", row.get::<_, u32>(1)?);
}

Ok(())
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -98,10 +52,4 @@ mod tests {
);
Ok(())
}

#[test]
fn test_read_idx_into_duck_db() -> anyhow::Result<()> {
read_idx_into_duck_db(String::from("FILENAME NOT USED YET!"))?;
Ok(())
}
}

0 comments on commit d1eeb91

Please sign in to comment.