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

mbrobbel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new 7c6a883302 Migrate `arrow-csv` to Rust 2024 (#8454)
7c6a883302 is described below

commit 7c6a883302551dde7e89bfed1779c74dac677a0a
Author: Matthijs Brobbel <[email protected]>
AuthorDate: Fri Sep 26 15:53:31 2025 +0200

    Migrate `arrow-csv` to Rust 2024 (#8454)
    
    # Which issue does this PR close?
    
    - Contribute to #6827
    
    # Rationale for this change
    
    Splitting up #8227.
    
    # What changes are included in this PR?
    
    Migrate `arrow-csv` to Rust 2024
    
    # Are these changes tested?
    
    CI
    
    # Are there any user-facing changes?
    
    Yes
---
 arrow-csv/Cargo.toml        |  2 +-
 arrow-csv/src/lib.rs        |  2 +-
 arrow-csv/src/reader/mod.rs | 22 +++++++++++++++++-----
 arrow-csv/src/writer.rs     |  7 +++++--
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/arrow-csv/Cargo.toml b/arrow-csv/Cargo.toml
index c44ec01ce3..f823226c21 100644
--- a/arrow-csv/Cargo.toml
+++ b/arrow-csv/Cargo.toml
@@ -25,7 +25,7 @@ authors = { workspace = true }
 license = { workspace = true }
 keywords = { workspace = true }
 include = { workspace = true }
-edition = { workspace = true }
+edition = "2024"
 rust-version = { workspace = true }
 
 [lib]
diff --git a/arrow-csv/src/lib.rs b/arrow-csv/src/lib.rs
index a3552eda8a..fd2f0d3d98 100644
--- a/arrow-csv/src/lib.rs
+++ b/arrow-csv/src/lib.rs
@@ -27,9 +27,9 @@
 pub mod reader;
 pub mod writer;
 
-pub use self::reader::infer_schema_from_files;
 pub use self::reader::Reader;
 pub use self::reader::ReaderBuilder;
+pub use self::reader::infer_schema_from_files;
 pub use self::writer::Writer;
 pub use self::writer::WriterBuilder;
 use arrow_schema::ArrowError;
diff --git a/arrow-csv/src/reader/mod.rs b/arrow-csv/src/reader/mod.rs
index d1fc4eb350..0a72b57e85 100644
--- a/arrow-csv/src/reader/mod.rs
+++ b/arrow-csv/src/reader/mod.rs
@@ -128,7 +128,7 @@ mod records;
 use arrow_array::builder::{NullBuilder, PrimitiveBuilder};
 use arrow_array::types::*;
 use arrow_array::*;
-use arrow_cast::parse::{parse_decimal, string_to_datetime, Parser};
+use arrow_cast::parse::{Parser, parse_decimal, string_to_datetime};
 use arrow_schema::*;
 use chrono::{TimeZone, Utc};
 use csv::StringRecord;
@@ -1853,7 +1853,10 @@ mod tests {
         let file_name = "test/data/various_invalid_types/invalid_float.csv";
 
         let error = invalid_csv_helper(file_name);
-        assert_eq!("Parser error: Error while parsing value '4.x4' as type 
'Float32' for column 1 at line 4. Row data: '[4,4.x4,,false]'", error);
+        assert_eq!(
+            "Parser error: Error while parsing value '4.x4' as type 'Float32' 
for column 1 at line 4. Row data: '[4,4.x4,,false]'",
+            error
+        );
     }
 
     #[test]
@@ -1861,7 +1864,10 @@ mod tests {
         let file_name = "test/data/various_invalid_types/invalid_int.csv";
 
         let error = invalid_csv_helper(file_name);
-        assert_eq!("Parser error: Error while parsing value '2.3' as type 
'UInt64' for column 0 at line 2. Row data: '[2.3,2.2,2.22,false]'", error);
+        assert_eq!(
+            "Parser error: Error while parsing value '2.3' as type 'UInt64' 
for column 0 at line 2. Row data: '[2.3,2.2,2.22,false]'",
+            error
+        );
     }
 
     #[test]
@@ -1869,7 +1875,10 @@ mod tests {
         let file_name = "test/data/various_invalid_types/invalid_bool.csv";
 
         let error = invalid_csv_helper(file_name);
-        assert_eq!("Parser error: Error while parsing value 'none' as type 
'Boolean' for column 3 at line 2. Row data: '[2,2.2,2.22,none]'", error);
+        assert_eq!(
+            "Parser error: Error while parsing value 'none' as type 'Boolean' 
for column 3 at line 2. Row data: '[2,2.2,2.22,none]'",
+            error
+        );
     }
 
     /// Infer the data type of a record
@@ -2697,7 +2706,10 @@ mod tests {
             .infer_schema(&mut read, None);
         assert!(result.is_err());
         // Include line number in the error message to help locate and fix the 
issue
-        assert_eq!(result.err().unwrap().to_string(), "Csv error: Encountered 
unequal lengths between records on CSV file. Expected 3 records, found 2 
records at line 3");
+        assert_eq!(
+            result.err().unwrap().to_string(),
+            "Csv error: Encountered unequal lengths between records on CSV 
file. Expected 3 records, found 2 records at line 3"
+        );
     }
 
     #[test]
diff --git a/arrow-csv/src/writer.rs b/arrow-csv/src/writer.rs
index e10943a6a9..3088c12c20 100644
--- a/arrow-csv/src/writer.rs
+++ b/arrow-csv/src/writer.rs
@@ -418,7 +418,7 @@ mod tests {
 
     use crate::ReaderBuilder;
     use arrow_array::builder::{
-        BinaryBuilder, Decimal128Builder, Decimal256Builder, Decimal32Builder, 
Decimal64Builder,
+        BinaryBuilder, Decimal32Builder, Decimal64Builder, Decimal128Builder, 
Decimal256Builder,
         FixedSizeBinaryBuilder, LargeBinaryBuilder,
     };
     use arrow_array::types::*;
@@ -717,7 +717,10 @@ sed do eiusmod 
tempor,-556132.25,1,,2019-04-18T02:45:55.555,23:46:03,foo
 
         for batch in batches {
             let err = writer.write(batch).unwrap_err().to_string();
-            assert_eq!(err, "Csv error: Error processing row 2, col 2: Cast 
error: Failed to convert 1926632005177685347 to temporal for Date64")
+            assert_eq!(
+                err,
+                "Csv error: Error processing row 2, col 2: Cast error: Failed 
to convert 1926632005177685347 to temporal for Date64"
+            )
         }
         drop(writer);
     }

Reply via email to