delta-io / kafka-delta-ingest

A highly efficient daemon for streaming data from Kafka into Delta Lake
Apache License 2.0
359 stars 79 forks source link

use of deprecated method `chrono::DateTime::<Tz>::timestamp_nanos`: use `timestamp_nanos_opt()` instead #156

Closed gdubya closed 9 months ago

gdubya commented 11 months ago

Error compiling the project with rustc 1.73.0

rustc 1.73.0 (cc66ad468 2023-10-03) cargo 1.73.0 (9c4383fb5 2023-08-26)

error: use of deprecated method `chrono::DateTime::<Tz>::timestamp_nanos`: use `timestamp_nanos_opt()` instead
   --> src/coercions.rs:141:52
    |
141 |         .map(|dt: DateTime<Utc>| Value::Number((dt.timestamp_nanos() / 1000).into()))
    |                                                    ^^^^^^^^^^^^^^^
    |
note: the lint level is defined here
   --> src/lib.rs:7:9
    |
7   | #![deny(warnings)]
    |         ^^^^^^^^
    = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]`

error: use of deprecated method `chrono::DateTime::<Tz>::timestamp_nanos`: use `timestamp_nanos_opt()` instead
  --> src/dead_letters.rs:47:34
   |
47 |             timestamp: timestamp.timestamp_nanos() / 1000,
   |                                  ^^^^^^^^^^^^^^^

error: use of deprecated method `chrono::DateTime::<Tz>::timestamp_nanos`: use `timestamp_nanos_opt()` instead
  --> src/dead_letters.rs:59:34
   |
59 |             timestamp: timestamp.timestamp_nanos() / 1000,
   |                                  ^^^^^^^^^^^^^^^

error: use of deprecated method `chrono::DateTime::<Tz>::timestamp_nanos`: use `timestamp_nanos_opt()` instead
  --> src/dead_letters.rs:72:34
   |
72 |             timestamp: timestamp.timestamp_nanos() / 1000,
gdubya commented 11 months ago

Is it safe / enough to simply replace the timestamp_nanos() usages with timestamp_nanos_opt().unwrap() ?

mightyshazam commented 11 months ago

Is it safe / enough to simply replace the timestamp_nanos() usages with timestamp_nanos_opt().unwrap() ?

It should be okay, given that the previous method would panic if invalid. It doesn't change behavior.

gdubya commented 10 months ago

Actually I think this error message was a result of me running cargo update at some point. I took a clean copy of the repo and ran cargo build using rustc 1.73 and it compiles fine (no "deprecated method" errors). So, the cause of the error needs a bit more investigation.

punitchauhan771 commented 10 months ago

Hi @gdubya I am not sure but this might be the issue since you updated your cargo, chrono version in Cargo.toml is set to "0", and it likely updated to the latest version (0.4.31), which introduced the deprecation warning since it was added in this version. reference link: https://github.com/chronotope/chrono/pull/1275