From cd4d961db960ff5871aa275a26f69fa64d4a8eff Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 1 May 2023 11:08:34 -0400 Subject: [PATCH 1/3] fix: garbage_collector no longer uses chrono-english so it can use the workspace hack crate --- .config/hakari.toml | 4 ---- Cargo.lock | 1 + garbage_collector/Cargo.toml | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.config/hakari.toml b/.config/hakari.toml index b64a9887e9..ca13621945 100644 --- a/.config/hakari.toml +++ b/.config/hakari.toml @@ -37,10 +37,6 @@ workspace-members = [ "influxdb-line-protocol", "influxdb2_client", "iox_data_generator", - # The garbage collector uses chrono-english which needlessly - # brings in chrono with the default features. This exclusion can - # likely be removed if they publish a version without that. - "garbage_collector", "mutable_batch_tests", ] third-party = [ diff --git a/Cargo.lock b/Cargo.lock index 20aad91fd2..1bb6247485 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2055,6 +2055,7 @@ dependencies = [ "tokio-stream", "tokio-util", "uuid", + "workspace-hack", ] [[package]] diff --git a/garbage_collector/Cargo.toml b/garbage_collector/Cargo.toml index 5eff830164..afe82e0f87 100644 --- a/garbage_collector/Cargo.toml +++ b/garbage_collector/Cargo.toml @@ -21,6 +21,7 @@ tokio = { version = "1", features = ["macros", "rt", "sync"] } tokio-stream = "0.1" tokio-util = { version = "0.7.8" } uuid = { version = "1", features = ["v4"] } +workspace-hack = { version = "0.1", path = "../workspace-hack" } [dev-dependencies] bytes = "1.4" From 0c4a86cbaa8fd9786258b64eb1d0893c070c84ca Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 1 May 2023 11:31:25 -0400 Subject: [PATCH 2/3] fix: Use humantime rather than chrono-english --- Cargo.lock | 16 ------------- Cargo.toml | 3 --- iox_data_generator/Cargo.toml | 1 - .../src/bin/iox_data_generator.rs | 24 ++++++++++++------- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1bb6247485..14029fe1d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -799,15 +799,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "chrono-english" -version = "0.1.6" -source = "git+https://github.com/stevedonovan/chrono-english.git?rev=def5941ebee24b55e1174eb18ab33d91603f907a#def5941ebee24b55e1174eb18ab33d91603f907a" -dependencies = [ - "chrono", - "scanlex", -] - [[package]] name = "chrono-tz" version = "0.8.2" @@ -2865,7 +2856,6 @@ version = "0.1.0" dependencies = [ "bytes", "chrono", - "chrono-english", "clap 4.2.5", "criterion", "datafusion_util", @@ -4912,12 +4902,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scanlex" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088c5d71572124929ea7549a8ce98e1a6fd33d0a38367b09027b382e67c033db" - [[package]] name = "schema" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 0b1c54db2a..c79e6e3e4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,7 +115,6 @@ license = "MIT OR Apache-2.0" [workspace.dependencies] arrow = { version = "38.0.0" } arrow-flight = { version = "38.0.0" } -chrono-english = { git = "https://github.com/stevedonovan/chrono-english.git", rev = "def5941ebee24b55e1174eb18ab33d91603f907a" } datafusion = { git = "https://github.com/apache/arrow-datafusion.git", rev="451e81eafe5e404de50f6ede1bebf25ed90f5eb0", default-features = false } datafusion-proto = { git = "https://github.com/apache/arrow-datafusion.git", rev="451e81eafe5e404de50f6ede1bebf25ed90f5eb0" } hashbrown = { version = "0.13.2" } @@ -125,8 +124,6 @@ tonic-build = { version = "0.9.2" } tonic-health = { version = "0.9.2" } tonic-reflection = { version = "0.9.2" } - - # This profile optimizes for runtime performance and small binary size at the expense of longer # build times. It's most suitable for final release builds. [profile.release] diff --git a/iox_data_generator/Cargo.toml b/iox_data_generator/Cargo.toml index 02af069083..c6b7999b72 100644 --- a/iox_data_generator/Cargo.toml +++ b/iox_data_generator/Cargo.toml @@ -9,7 +9,6 @@ license.workspace = true [dependencies] bytes = "1.4" chrono = { version = "0.4", default-features = false } -chrono-english = { workspace = true } clap = { version = "4", features = ["derive", "env", "cargo"] } datafusion_util = { path = "../datafusion_util" } futures = "0.3" diff --git a/iox_data_generator/src/bin/iox_data_generator.rs b/iox_data_generator/src/bin/iox_data_generator.rs index ac71ad1ebd..11c4ee9938 100644 --- a/iox_data_generator/src/bin/iox_data_generator.rs +++ b/iox_data_generator/src/bin/iox_data_generator.rs @@ -11,7 +11,6 @@ )] use chrono::prelude::*; -use chrono_english::{parse_date_string, Dialect}; use iox_data_generator::{specification::DataSpec, write::PointsWriterBuilder}; use std::{ fs::File, @@ -38,7 +37,7 @@ Examples: # Generate data points starting from an hour ago until now, generating the historical data as # fast as possible. Then generate data according to the sampling interval until terminated. - iox_data_generator -s spec.toml -o lp --start "1 hr ago" --continue + iox_data_generator -s spec.toml -o lp --start "1 hr" --continue Logging: Use the RUST_LOG environment variable to configure the desired logging level. @@ -103,14 +102,14 @@ struct Config { /// The date and time at which to start the timestamps of the generated data. /// /// Can be an exact datetime like `2020-01-01T01:23:45-05:00` or a fuzzy - /// specification like `1 hour ago`. If not specified, defaults to no. + /// specification like `1 hour`. If not specified, defaults to no. #[clap(long, action)] start: Option, /// The date and time at which to stop the timestamps of the generated data. /// /// Can be an exact datetime like `2020-01-01T01:23:45-05:00` or a fuzzy - /// specification like `1 hour ago`. If not specified, defaults to now. + /// specification like `1 hour`. If not specified, defaults to now. #[clap(long, action)] end: Option, @@ -222,7 +221,15 @@ async fn main() -> Result<(), Box> { fn datetime_nanoseconds(arg: Option<&str>, now: DateTime) -> Option { arg.map(|s| { - let datetime = parse_date_string(s, now, Dialect::Us).expect("Could not parse time"); + let datetime = humantime::parse_rfc3339(s) + .map(Into::into) + .unwrap_or_else(|_| { + let std_duration = humantime::parse_duration(s).expect("Could not parse time"); + let chrono_duration = chrono::Duration::from_std(std_duration) + .expect("Could not convert std::time::Duration to chrono::Duration"); + now - chrono_duration + }); + datetime.timestamp_nanos() }) } @@ -238,16 +245,15 @@ mod test { } #[test] - #[ignore] // TODO: I think chrono-english isn't handling timezones the way I'd expect fn rfc3339() { - let ns = datetime_nanoseconds(Some("2020-01-01T01:23:45-05:00"), Local::now()); - assert_eq!(ns, Some(1577859825000000000)); + let ns = datetime_nanoseconds(Some("2020-01-01T01:23:45Z"), Local::now()); + assert_eq!(ns, Some(1_577_841_825_000_000_000)); } #[test] fn relative() { let fixed_now = Local::now(); - let ns = datetime_nanoseconds(Some("1hr ago"), fixed_now); + let ns = datetime_nanoseconds(Some("1hr"), fixed_now); let expected = (fixed_now - chrono::Duration::hours(1)).timestamp_nanos(); assert_eq!(ns, Some(expected)); } From f7eb465ee6c99a66d9f219535b66f21da2c8c05f Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 1 May 2023 11:15:02 -0400 Subject: [PATCH 3/3] fix: Add chrono-english to the cargo-deny config to avoid pulling it in again in the future --- deny.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deny.toml b/deny.toml index a105ce3e98..3d8f72da17 100644 --- a/deny.toml +++ b/deny.toml @@ -56,5 +56,8 @@ deny = [ # If you're hitting this, you might want to take a look at what new # dependencies you have introduced and check if there's a way to depend on # rustls instead of OpenSSL (tip: check the crate's feature flags). - { name = "openssl-sys" } + { name = "openssl-sys" }, + # We've decided to use the `humantime` crate to parse and generate friendly time formats; use + # that rather than chrono-english. + { name = "chrono-english" }, ]