-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate old JSON reader (#3610) #3718
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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<Option<String>> { | |||||
/// [`RawReader`]: crate::raw::RawReader | ||||||
/// [#3610]: https://github.com/apache/arrow-rs/issues/3610 | ||||||
Comment on lines
1606
to
1607
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto.
Suggested change
|
||||||
#[derive(Debug)] | ||||||
#[deprecated(note = "Use RawReader instead")] | ||||||
#[allow(deprecated)] | ||||||
pub struct Reader<R: Read> { | ||||||
reader: BufReader<R>, | ||||||
/// JSON value decoder | ||||||
decoder: Decoder, | ||||||
} | ||||||
|
||||||
#[allow(deprecated)] | ||||||
impl<R: Read> Reader<R> { | ||||||
/// Create a new JSON Reader from any value that implements the `Read` trait. | ||||||
/// | ||||||
|
@@ -1656,6 +1661,7 @@ impl<R: Read> Reader<R> { | |||||
/// [#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<R: Read> Iterator for Reader<R> { | ||||||
type Item = Result<RecordBatch, ArrowError>; | ||||||
|
||||||
|
@@ -1759,6 +1767,7 @@ impl<R: Read> Iterator for Reader<R> { | |||||
} | ||||||
|
||||||
#[cfg(test)] | ||||||
#[allow(deprecated)] | ||||||
mod tests { | ||||||
use super::*; | ||||||
use arrow_array::cast::{ | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't actually valid JSON, it contained a duplicate key - the RawReader handles this differently (preserving the duplicate) than the old JSON reader which preserves only the last instance There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds like behavior change. Do we have document it at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The prior behaviour wasn't documented on |
||
{"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(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need the comment? Actually it reads unclear and seems strange to put issue link there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are link shorthand, they don't get rendered, but are used to attach links to the text above.