diff --git a/arrow-json/src/lib.rs b/arrow-json/src/lib.rs index 7e582c3359a6..5998bc3a4433 100644 --- a/arrow-json/src/lib.rs +++ b/arrow-json/src/lib.rs @@ -28,6 +28,7 @@ pub mod writer; mod raw; pub use self::raw::{RawDecoder, RawReader, RawReaderBuilder}; +#[allow(deprecated)] pub use self::reader::{Reader, ReaderBuilder}; pub use self::writer::{ArrayWriter, LineDelimitedWriter, Writer}; use half::f16; diff --git a/arrow-json/src/raw/mod.rs b/arrow-json/src/raw/mod.rs index a45ff8ea85eb..82a85a16b641 100644 --- a/arrow-json/src/raw/mod.rs +++ b/arrow-json/src/raw/mod.rs @@ -295,6 +295,7 @@ fn tape_error(d: TapeElement, expected: &str) -> ArrowError { } #[cfg(test)] +#[allow(deprecated)] mod tests { use super::*; use crate::reader::infer_json_schema; diff --git a/arrow-json/src/reader.rs b/arrow-json/src/reader.rs index 1d4cfc740fdf..91852b4b314e 100644 --- a/arrow-json/src/reader.rs +++ b/arrow-json/src/reader.rs @@ -582,6 +582,7 @@ where /// [`RawDecoder`]: crate::raw::RawDecoder /// [#3610]: https://github.com/apache/arrow-rs/issues/3610 #[derive(Debug)] +#[deprecated(note = "Use RawDecoder instead")] pub struct Decoder { /// Explicit schema for the JSON file schema: SchemaRef, @@ -638,6 +639,7 @@ impl DecoderOptions { } } +#[allow(deprecated)] impl Decoder { /// Create a new JSON decoder from some value that implements an /// iterator over [`serde_json::Value`]s (aka implements the @@ -1604,12 +1606,15 @@ fn flatten_json_string_values(values: &[Value]) -> Vec> { /// [`RawReader`]: crate::raw::RawReader /// [#3610]: https://github.com/apache/arrow-rs/issues/3610 #[derive(Debug)] +#[deprecated(note = "Use RawReader instead")] +#[allow(deprecated)] pub struct Reader { reader: BufReader, /// JSON value decoder decoder: Decoder, } +#[allow(deprecated)] impl Reader { /// Create a new JSON Reader from any value that implements the `Read` trait. /// @@ -1656,6 +1661,7 @@ impl Reader { /// [#3610]: https://github.com/apache/arrow-rs/issues/3610 /// #[derive(Debug, Default)] +#[deprecated(note = "Use RawReaderBuilder instead")] pub struct ReaderBuilder { /// Optional schema for the JSON file /// @@ -1670,6 +1676,7 @@ pub struct ReaderBuilder { options: DecoderOptions, } +#[allow(deprecated)] impl ReaderBuilder { /// Create a new builder for configuring JSON parsing options. /// @@ -1750,6 +1757,7 @@ impl ReaderBuilder { } } +#[allow(deprecated)] impl Iterator for Reader { type Item = Result; @@ -1759,6 +1767,7 @@ impl Iterator for Reader { } #[cfg(test)] +#[allow(deprecated)] mod tests { use super::*; use arrow_array::cast::{ diff --git a/arrow-json/src/writer.rs b/arrow-json/src/writer.rs index 028b7d889157..27ae3876441d 100644 --- a/arrow-json/src/writer.rs +++ b/arrow-json/src/writer.rs @@ -1218,6 +1218,7 @@ mod tests { ); } + #[allow(deprecated)] fn test_write_for_file(test_file: &str) { let builder = ReaderBuilder::new() .infer_schema(None) @@ -1295,6 +1296,7 @@ mod tests { } #[test] + #[allow(deprecated)] fn json_list_roundtrip() { let json_content = r#" {"list": [{"ints": 1}]} @@ -1406,6 +1408,7 @@ mod tests { } #[test] + #[allow(deprecated)] fn test_write_single_batch() { let test_file = "test/data/basic.json"; let builder = ReaderBuilder::new() diff --git a/arrow/benches/json_reader.rs b/arrow/benches/json_reader.rs index b5d8a53679ef..5651813a6403 100644 --- a/arrow/benches/json_reader.rs +++ b/arrow/benches/json_reader.rs @@ -22,16 +22,17 @@ use arrow::util::bench_util::{ create_primitive_array, create_string_array, create_string_array_with_len, }; use arrow_array::RecordBatch; +use arrow_json::LineDelimitedWriter; use arrow_json::RawReaderBuilder; -use arrow_json::{LineDelimitedWriter, ReaderBuilder}; use std::io::Cursor; use std::sync::Arc; +#[allow(deprecated)] fn do_bench(c: &mut Criterion, name: &str, json: &str, schema: SchemaRef) { c.bench_function(&format!("{name} (basic)"), |b| { b.iter(|| { let cursor = Cursor::new(black_box(json)); - let builder = ReaderBuilder::new() + let builder = arrow_json::ReaderBuilder::new() .with_schema(schema.clone()) .with_batch_size(64); diff --git a/parquet/src/arrow/arrow_writer/levels.rs b/parquet/src/arrow/arrow_writer/levels.rs index f427ce3e19e4..11ed35263e6a 100644 --- a/parquet/src/arrow/arrow_writer/levels.rs +++ b/parquet/src/arrow/arrow_writer/levels.rs @@ -1121,7 +1121,7 @@ mod tests { // Note: we are using the JSON Arrow reader for brevity let json_content = r#" {"stocks":{"long": "$AAA", "short": "$BBB"}} - {"stocks":{"long": null, "long": "$CCC", "short": null}} + {"stocks":{"long": "$CCC", "short": null}} {"stocks":{"hedged": "$YYY", "long": null, "short": "$D"}} "#; let entries_struct_type = DataType::Struct(vec![ @@ -1138,9 +1138,7 @@ mod tests { false, ); let schema = Arc::new(Schema::new(vec![stocks_field])); - let builder = arrow::json::ReaderBuilder::new() - .with_schema(schema) - .with_batch_size(64); + let builder = arrow::json::RawReaderBuilder::new(schema).with_batch_size(64); let mut reader = builder.build(std::io::Cursor::new(json_content)).unwrap(); let batch = reader.next().unwrap().unwrap(); diff --git a/parquet/src/arrow/arrow_writer/mod.rs b/parquet/src/arrow/arrow_writer/mod.rs index 6260c2ed4d0d..e6693a6cff4a 100644 --- a/parquet/src/arrow/arrow_writer/mod.rs +++ b/parquet/src/arrow/arrow_writer/mod.rs @@ -1026,9 +1026,7 @@ mod tests { true, ); let schema = Arc::new(Schema::new(vec![stocks_field])); - let builder = arrow::json::ReaderBuilder::new() - .with_schema(schema) - .with_batch_size(64); + let builder = arrow::json::RawReaderBuilder::new(schema).with_batch_size(64); let mut reader = builder.build(std::io::Cursor::new(json_content)).unwrap(); let batch = reader.next().unwrap().unwrap();