This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-fury.git


The following commit(s) were added to refs/heads/main by this push:
     new 7ac2c6eb chore(rust): resolve deprecate warnings (#1662)
7ac2c6eb is described below

commit 7ac2c6eb50d08c112d7a599169aa48766de221dc
Author: Ruihang Xia <[email protected]>
AuthorDate: Thu May 30 23:38:35 2024 +0800

    chore(rust): resolve deprecate warnings (#1662)
    
    <!--
    **Thanks for contributing to Fury.**
    
    **If this is your first time opening a PR on fury, you can refer to
    
[CONTRIBUTING.md](https://github.com/apache/incubator-fury/blob/main/CONTRIBUTING.md).**
    
    Contribution Checklist
    
    - The **Apache Fury (incubating)** community has restrictions on the
    naming of pr titles. You can also find instructions in
    
[CONTRIBUTING.md](https://github.com/apache/incubator-fury/blob/main/CONTRIBUTING.md).
    
    - Fury has a strong focus on performance. If the PR you submit will have
    an impact on performance, please benchmark it first and provide the
    benchmark result here.
    -->
    
    ## What does this PR do?
    
    <!-- Describe the purpose of this PR. -->
    
    - Resolve deprecate warnings from `chrono` dep
    - Remove patch version in Cargo.toml
    
    ## Related issues
    
    <!--
    Is there any related issue? Please attach here.
    
    - #xxxx0
    - #xxxx1
    - #xxxx2
    -->
    
    N/A
    
    ## Does this PR introduce any user-facing change?
    
    <!--
    If any user-facing interface changes, please [open an
    issue](https://github.com/apache/incubator-fury/issues/new/choose)
    describing the need to do so and update the document if necessary.
    -->
    
    - [ ] Does this PR introduce any public API change?
    - [ ] Does this PR introduce any binary protocol compatibility change?
    
    No
    
    ## Benchmark
    
    <!--
    When the PR has an impact on performance (if you don't know whether the
    PR will have an impact on performance, you can submit the PR first, and
    if it will have impact on performance, the code reviewer will explain
    it), be sure to attach a benchmark data here.
    -->
    
    Signed-off-by: Ruihang Xia <[email protected]>
---
 rust/fury-derive/Cargo.toml             | 13 +++++++++----
 rust/fury/Cargo.toml                    | 16 ++++++++--------
 rust/fury/src/deserializer.rs           |  2 +-
 rust/fury/src/row/row.rs                |  6 +++---
 rust/fury/src/serializer.rs             |  4 +++-
 rust/tests/Cargo.toml                   |  4 ++--
 rust/tests/tests/test_complex_struct.rs |  4 ++--
 7 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/rust/fury-derive/Cargo.toml b/rust/fury-derive/Cargo.toml
index 1034fe26..ced37343 100644
--- a/rust/fury-derive/Cargo.toml
+++ b/rust/fury-derive/Cargo.toml
@@ -25,7 +25,12 @@ rust-version.workspace = true
 proc-macro = true
 
 [dependencies]
-proc-macro2 = { default-features = false, version = "1.0.66" }
-syn = { default-features = false, version = "2.0.26", features = ["parsing", 
"proc-macro", "derive", "printing"] }
-quote = { default-features = false, version = "1.0.31" }
-thiserror = { default-features = false, version = "1.0.43" }
+proc-macro2 = { default-features = false, version = "1.0" }
+syn = { default-features = false, version = "2.0", features = [
+    "parsing",
+    "proc-macro",
+    "derive",
+    "printing",
+] }
+quote = { default-features = false, version = "1.0" }
+thiserror = { default-features = false, version = "1.0" }
diff --git a/rust/fury/Cargo.toml b/rust/fury/Cargo.toml
index ed24f0cd..d39d5375 100644
--- a/rust/fury/Cargo.toml
+++ b/rust/fury/Cargo.toml
@@ -22,11 +22,11 @@ edition.workspace = true
 rust-version.workspace = true
 
 [dependencies]
-proc-macro2 = { default-features = false, version = "1.0.66" }
-syn = { default-features = false, version = "2.0.26", features = ["full", 
"fold"] }
-quote = { default-features = false, version = "1.0.31" }
-fury-derive = { path="../fury-derive"}
-lazy_static = { version = "1.4.0" }
-byteorder = { version = "1.4.3" }
-chrono = "0.4.26"
-thiserror = { default-features = false, version = "1.0.43" }
\ No newline at end of file
+proc-macro2 = { default-features = false, version = "1.0" }
+syn = { default-features = false, version = "2.0", features = ["full", "fold"] 
}
+quote = { default-features = false, version = "1.0" }
+fury-derive = { path = "../fury-derive" }
+lazy_static = { version = "1.4" }
+byteorder = { version = "1.4" }
+chrono = "0.4"
+thiserror = { default-features = false, version = "1.0" }
diff --git a/rust/fury/src/deserializer.rs b/rust/fury/src/deserializer.rs
index ac443ea3..764f5595 100644
--- a/rust/fury/src/deserializer.rs
+++ b/rust/fury/src/deserializer.rs
@@ -166,7 +166,7 @@ impl<T: Deserialize + Eq + std::hash::Hash> Deserialize for 
HashSet<T> {
 impl Deserialize for NaiveDateTime {
     fn read(deserializer: &mut DeserializerState) -> Result<Self, Error> {
         let timestamp = deserializer.reader.u64();
-        let ret = NaiveDateTime::from_timestamp_millis(timestamp as i64);
+        let ret = DateTime::from_timestamp_millis(timestamp as i64).map(|dt| 
dt.naive_utc());
         match ret {
             Some(r) => Ok(r),
             None => Err(Error::NaiveDateTime),
diff --git a/rust/fury/src/row/row.rs b/rust/fury/src/row/row.rs
index 28c32e6b..be0f6591 100644
--- a/rust/fury/src/row/row.rs
+++ b/rust/fury/src/row/row.rs
@@ -17,7 +17,7 @@
 
 use crate::{buffer::Writer, Error};
 use byteorder::{ByteOrder, LittleEndian};
-use chrono::{Days, NaiveDate, NaiveDateTime};
+use chrono::{DateTime, Days, NaiveDate, NaiveDateTime};
 use std::collections::BTreeMap;
 use std::marker::PhantomData;
 
@@ -109,12 +109,12 @@ impl<'a> Row<'a> for NaiveDateTime {
     type ReadResult = Result<NaiveDateTime, Error>;
 
     fn write(v: &Self, writer: &mut Writer) {
-        writer.i64(v.timestamp_millis());
+        writer.i64(v.and_utc().timestamp_millis());
     }
 
     fn cast(bytes: &[u8]) -> Self::ReadResult {
         let timestamp = LittleEndian::read_u64(bytes);
-        let ret = NaiveDateTime::from_timestamp_millis(timestamp as i64);
+        let ret = DateTime::from_timestamp_millis(timestamp as i64).map(|dt| 
dt.naive_utc());
         match ret {
             Some(r) => Ok(r),
             None => Err(Error::NaiveDateTime),
diff --git a/rust/fury/src/serializer.rs b/rust/fury/src/serializer.rs
index fe5c7e75..f22c1636 100644
--- a/rust/fury/src/serializer.rs
+++ b/rust/fury/src/serializer.rs
@@ -236,7 +236,9 @@ impl<T: Serialize> Serialize for HashSet<T> {
 
 impl Serialize for NaiveDateTime {
     fn write(&self, serializer: &mut SerializerState) {
-        serializer.writer.u64(self.timestamp_millis() as u64);
+        serializer
+            .writer
+            .u64(self.and_utc().timestamp_millis() as u64);
     }
 
     fn reserved_space() -> usize {
diff --git a/rust/tests/Cargo.toml b/rust/tests/Cargo.toml
index 1b35ee12..340411c1 100644
--- a/rust/tests/Cargo.toml
+++ b/rust/tests/Cargo.toml
@@ -26,5 +26,5 @@ publish = false
 fury = { path = "../fury" }
 fury-derive = { path = "../fury-derive" }
 
-chrono = "0.4.26"
-lazy_static = { version = "1.4.0" }
+chrono = "0.4"
+lazy_static = { version = "1.4" }
diff --git a/rust/tests/tests/test_complex_struct.rs 
b/rust/tests/tests/test_complex_struct.rs
index cc4a5b92..b114db42 100644
--- a/rust/tests/tests/test_complex_struct.rs
+++ b/rust/tests/tests/test_complex_struct.rs
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use chrono::{NaiveDate, NaiveDateTime};
+use chrono::{DateTime, NaiveDate, NaiveDateTime};
 use fury::{from_buffer, to_buffer, Fury};
 use std::collections::HashMap;
 
@@ -60,7 +60,7 @@ fn complex_struct() {
         op: Some("option".to_string()),
         op2: None,
         date: NaiveDate::from_ymd_opt(2025, 12, 12).unwrap(),
-        time: NaiveDateTime::from_timestamp_opt(1689912359, 0).unwrap(),
+        time: DateTime::from_timestamp(1689912359, 0).unwrap().naive_utc(),
         c5: 2.0,
         c6: 4.0,
     };


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to