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 2ad689a5aa Migrate `arrow-json` to Rust 2024 (#8458)
2ad689a5aa is described below
commit 2ad689a5aaf32411de1c13f737a52382910f0e6e
Author: Matthijs Brobbel <[email protected]>
AuthorDate: Fri Sep 26 15:55:20 2025 +0200
Migrate `arrow-json` to Rust 2024 (#8458)
# 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-json` to Rust 2024
# Are these changes tested?
CI
# Are there any user-facing changes?
Yes
---
arrow-json/Cargo.toml | 2 +-
arrow-json/benches/serde.rs | 2 +-
arrow-json/src/reader/boolean_array.rs | 4 ++--
arrow-json/src/reader/decimal_array.rs | 4 ++--
arrow-json/src/reader/list_array.rs | 6 +++---
arrow-json/src/reader/map_array.rs | 10 +++++-----
arrow-json/src/reader/mod.rs | 2 +-
arrow-json/src/reader/null_array.rs | 2 +-
arrow-json/src/reader/primitive_array.rs | 2 +-
arrow-json/src/reader/string_array.rs | 2 +-
arrow-json/src/reader/string_view_array.rs | 4 ++--
arrow-json/src/reader/struct_array.rs | 2 +-
arrow-json/src/reader/tape.rs | 5 ++++-
arrow-json/src/reader/timestamp_array.rs | 4 ++--
arrow-json/src/writer/mod.rs | 8 ++++----
15 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/arrow-json/Cargo.toml b/arrow-json/Cargo.toml
index 1324c287aa..052493cf74 100644
--- a/arrow-json/Cargo.toml
+++ b/arrow-json/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-json/benches/serde.rs b/arrow-json/benches/serde.rs
index 7baaac458f..23f005cc90 100644
--- a/arrow-json/benches/serde.rs
+++ b/arrow-json/benches/serde.rs
@@ -18,7 +18,7 @@
use arrow_json::ReaderBuilder;
use arrow_schema::{DataType, Field, Schema};
use criterion::*;
-use rand::{rng, Rng};
+use rand::{Rng, rng};
use serde::Serialize;
use std::sync::Arc;
diff --git a/arrow-json/src/reader/boolean_array.rs
b/arrow-json/src/reader/boolean_array.rs
index 9094391cd7..cb2587edcb 100644
--- a/arrow-json/src/reader/boolean_array.rs
+++ b/arrow-json/src/reader/boolean_array.rs
@@ -15,13 +15,13 @@
// specific language governing permissions and limitations
// under the License.
-use arrow_array::builder::BooleanBuilder;
use arrow_array::Array;
+use arrow_array::builder::BooleanBuilder;
use arrow_data::ArrayData;
use arrow_schema::ArrowError;
-use crate::reader::tape::{Tape, TapeElement};
use crate::reader::ArrayDecoder;
+use crate::reader::tape::{Tape, TapeElement};
#[derive(Default)]
pub struct BooleanArrayDecoder {}
diff --git a/arrow-json/src/reader/decimal_array.rs
b/arrow-json/src/reader/decimal_array.rs
index d56afcfe80..07a5e182a3 100644
--- a/arrow-json/src/reader/decimal_array.rs
+++ b/arrow-json/src/reader/decimal_array.rs
@@ -17,15 +17,15 @@
use std::marker::PhantomData;
+use arrow_array::Array;
use arrow_array::builder::PrimitiveBuilder;
use arrow_array::types::DecimalType;
-use arrow_array::Array;
use arrow_cast::parse::parse_decimal;
use arrow_data::ArrayData;
use arrow_schema::ArrowError;
-use crate::reader::tape::{Tape, TapeElement};
use crate::reader::ArrayDecoder;
+use crate::reader::tape::{Tape, TapeElement};
pub struct DecimalArrayDecoder<D: DecimalType> {
precision: u8,
diff --git a/arrow-json/src/reader/list_array.rs
b/arrow-json/src/reader/list_array.rs
index 1a1dee6a23..e74fef7917 100644
--- a/arrow-json/src/reader/list_array.rs
+++ b/arrow-json/src/reader/list_array.rs
@@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-use crate::reader::tape::{Tape, TapeElement};
-use crate::reader::{make_decoder, ArrayDecoder};
use crate::StructMode;
-use arrow_array::builder::{BooleanBufferBuilder, BufferBuilder};
+use crate::reader::tape::{Tape, TapeElement};
+use crate::reader::{ArrayDecoder, make_decoder};
use arrow_array::OffsetSizeTrait;
+use arrow_array::builder::{BooleanBufferBuilder, BufferBuilder};
use arrow_buffer::buffer::NullBuffer;
use arrow_data::{ArrayData, ArrayDataBuilder};
use arrow_schema::{ArrowError, DataType};
diff --git a/arrow-json/src/reader/map_array.rs
b/arrow-json/src/reader/map_array.rs
index ee78373a55..c2068577a0 100644
--- a/arrow-json/src/reader/map_array.rs
+++ b/arrow-json/src/reader/map_array.rs
@@ -15,12 +15,12 @@
// specific language governing permissions and limitations
// under the License.
-use crate::reader::tape::{Tape, TapeElement};
-use crate::reader::{make_decoder, ArrayDecoder};
use crate::StructMode;
+use crate::reader::tape::{Tape, TapeElement};
+use crate::reader::{ArrayDecoder, make_decoder};
use arrow_array::builder::{BooleanBufferBuilder, BufferBuilder};
-use arrow_buffer::buffer::NullBuffer;
use arrow_buffer::ArrowNativeType;
+use arrow_buffer::buffer::NullBuffer;
use arrow_data::{ArrayData, ArrayDataBuilder};
use arrow_schema::{ArrowError, DataType};
@@ -43,14 +43,14 @@ impl MapArrayDecoder {
DataType::Map(_, true) => {
return Err(ArrowError::NotYetImplemented(
"Decoding MapArray with sorted fields".to_string(),
- ))
+ ));
}
DataType::Map(f, _) => match f.data_type() {
DataType::Struct(fields) if fields.len() == 2 => fields,
d => {
return Err(ArrowError::InvalidArgumentError(format!(
"MapArray must contain struct with two fields, got {d}"
- )))
+ )));
}
},
_ => unreachable!(),
diff --git a/arrow-json/src/reader/mod.rs b/arrow-json/src/reader/mod.rs
index d58a1d03f7..e4658f8653 100644
--- a/arrow-json/src/reader/mod.rs
+++ b/arrow-json/src/reader/mod.rs
@@ -142,7 +142,7 @@ use serde::Serialize;
use arrow_array::timezone::Tz;
use arrow_array::types::*;
-use arrow_array::{downcast_integer, make_array, RecordBatch,
RecordBatchReader, StructArray};
+use arrow_array::{RecordBatch, RecordBatchReader, StructArray,
downcast_integer, make_array};
use arrow_data::ArrayData;
use arrow_schema::{ArrowError, DataType, FieldRef, Schema, SchemaRef,
TimeUnit};
pub use schema::*;
diff --git a/arrow-json/src/reader/null_array.rs
b/arrow-json/src/reader/null_array.rs
index 4270045fb3..aa16678c0a 100644
--- a/arrow-json/src/reader/null_array.rs
+++ b/arrow-json/src/reader/null_array.rs
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-use crate::reader::tape::{Tape, TapeElement};
use crate::reader::ArrayDecoder;
+use crate::reader::tape::{Tape, TapeElement};
use arrow_data::{ArrayData, ArrayDataBuilder};
use arrow_schema::{ArrowError, DataType};
diff --git a/arrow-json/src/reader/primitive_array.rs
b/arrow-json/src/reader/primitive_array.rs
index bf6c0a86f3..fa8464aa32 100644
--- a/arrow-json/src/reader/primitive_array.rs
+++ b/arrow-json/src/reader/primitive_array.rs
@@ -25,8 +25,8 @@ use arrow_data::ArrayData;
use arrow_schema::{ArrowError, DataType};
use half::f16;
-use crate::reader::tape::{Tape, TapeElement};
use crate::reader::ArrayDecoder;
+use crate::reader::tape::{Tape, TapeElement};
/// A trait for JSON-specific primitive parsing logic
///
diff --git a/arrow-json/src/reader/string_array.rs
b/arrow-json/src/reader/string_array.rs
index 03d07ad8c8..1ccb1ab03f 100644
--- a/arrow-json/src/reader/string_array.rs
+++ b/arrow-json/src/reader/string_array.rs
@@ -21,8 +21,8 @@ use arrow_data::ArrayData;
use arrow_schema::ArrowError;
use std::marker::PhantomData;
-use crate::reader::tape::{Tape, TapeElement};
use crate::reader::ArrayDecoder;
+use crate::reader::tape::{Tape, TapeElement};
const TRUE: &str = "true";
const FALSE: &str = "false";
diff --git a/arrow-json/src/reader/string_view_array.rs
b/arrow-json/src/reader/string_view_array.rs
index 44f7e3fd6a..dbc27e9c50 100644
--- a/arrow-json/src/reader/string_view_array.rs
+++ b/arrow-json/src/reader/string_view_array.rs
@@ -15,15 +15,15 @@
// specific language governing permissions and limitations
// under the License.
+use arrow_array::Array;
use arrow_array::builder::GenericByteViewBuilder;
use arrow_array::types::StringViewType;
-use arrow_array::Array;
use arrow_data::ArrayData;
use arrow_schema::ArrowError;
use std::fmt::Write;
-use crate::reader::tape::{Tape, TapeElement};
use crate::reader::ArrayDecoder;
+use crate::reader::tape::{Tape, TapeElement};
const TRUE: &str = "true";
const FALSE: &str = "false";
diff --git a/arrow-json/src/reader/struct_array.rs
b/arrow-json/src/reader/struct_array.rs
index f81a40c71e..262097ace3 100644
--- a/arrow-json/src/reader/struct_array.rs
+++ b/arrow-json/src/reader/struct_array.rs
@@ -16,7 +16,7 @@
// under the License.
use crate::reader::tape::{Tape, TapeElement};
-use crate::reader::{make_decoder, ArrayDecoder, StructMode};
+use crate::reader::{ArrayDecoder, StructMode, make_decoder};
use arrow_array::builder::BooleanBufferBuilder;
use arrow_buffer::buffer::NullBuffer;
use arrow_data::{ArrayData, ArrayDataBuilder};
diff --git a/arrow-json/src/reader/tape.rs b/arrow-json/src/reader/tape.rs
index 26236960a7..e3e42ae1cc 100644
--- a/arrow-json/src/reader/tape.rs
+++ b/arrow-json/src/reader/tape.rs
@@ -567,7 +567,10 @@ impl TapeDecoder {
}
if self.offsets.len() >= u32::MAX as usize {
- return Err(ArrowError::JsonError(format!("Encountered more than {}
bytes of string data, consider using a smaller batch size", u32::MAX)));
+ return Err(ArrowError::JsonError(format!(
+ "Encountered more than {} bytes of string data, consider using
a smaller batch size",
+ u32::MAX
+ )));
}
if self.offsets.len() >= u32::MAX as usize {
diff --git a/arrow-json/src/reader/timestamp_array.rs
b/arrow-json/src/reader/timestamp_array.rs
index ee90187029..79f2b04eeb 100644
--- a/arrow-json/src/reader/timestamp_array.rs
+++ b/arrow-json/src/reader/timestamp_array.rs
@@ -18,15 +18,15 @@
use chrono::TimeZone;
use std::marker::PhantomData;
+use arrow_array::Array;
use arrow_array::builder::PrimitiveBuilder;
use arrow_array::types::ArrowTimestampType;
-use arrow_array::Array;
use arrow_cast::parse::string_to_datetime;
use arrow_data::ArrayData;
use arrow_schema::{ArrowError, DataType, TimeUnit};
-use crate::reader::tape::{Tape, TapeElement};
use crate::reader::ArrayDecoder;
+use crate::reader::tape::{Tape, TapeElement};
/// A specialized [`ArrayDecoder`] for timestamps
pub struct TimestampArrayDecoder<P: ArrowTimestampType, Tz: TimeZone> {
diff --git a/arrow-json/src/writer/mod.rs b/arrow-json/src/writer/mod.rs
index a9d62bd96e..c14182b7b1 100644
--- a/arrow-json/src/writer/mod.rs
+++ b/arrow-json/src/writer/mod.rs
@@ -112,7 +112,7 @@ use crate::StructMode;
use arrow_array::*;
use arrow_schema::*;
-pub use encoder::{make_encoder, Encoder, EncoderFactory, EncoderOptions,
NullableEncoder};
+pub use encoder::{Encoder, EncoderFactory, EncoderOptions, NullableEncoder,
make_encoder};
/// This trait defines how to format a sequence of JSON objects to a
/// byte stream.
@@ -450,18 +450,18 @@ where
mod tests {
use core::str;
use std::collections::HashMap;
- use std::fs::{read_to_string, File};
+ use std::fs::{File, read_to_string};
use std::io::{BufReader, Seek};
use std::sync::Arc;
use arrow_array::cast::AsArray;
- use serde_json::{json, Value};
+ use serde_json::{Value, json};
use super::LineDelimited;
use super::{Encoder, WriterBuilder};
use arrow_array::builder::*;
use arrow_array::types::*;
- use arrow_buffer::{i256, Buffer, NullBuffer, OffsetBuffer, ScalarBuffer,
ToByteSlice};
+ use arrow_buffer::{Buffer, NullBuffer, OffsetBuffer, ScalarBuffer,
ToByteSlice, i256};
use arrow_data::ArrayData;
use crate::reader::*;