Support Arbitrary JSON values in JSON Reader (#4905)#4911
Merged
tustvold merged 4 commits intoapache:masterfrom Oct 12, 2023
Merged
Support Arbitrary JSON values in JSON Reader (#4905)#4911tustvold merged 4 commits intoapache:masterfrom
tustvold merged 4 commits intoapache:masterfrom
Conversation
Contributor
Author
|
This does represent a fairly minor performance regression, but I'm not too concerned |
alamb
approved these changes
Oct 10, 2023
arrow-json/src/reader/mod.rs
Outdated
Comment on lines
+24
to
+26
| //! The reader is agnostic to whitespace, including `\n` and `\r`, and will ignore such characters. | ||
| //! This allows parsing sequences of one or more arbitrarily formatted JSON values, including | ||
| //! but not limited to newline-delimited JSON. |
Contributor
There was a problem hiding this comment.
A minor suggestion to improve the wording here
Suggested change
| //! The reader is agnostic to whitespace, including `\n` and `\r`, and will ignore such characters. | |
| //! This allows parsing sequences of one or more arbitrarily formatted JSON values, including | |
| //! but not limited to newline-delimited JSON. | |
| //! The reader ignores whitespace between JSON values, including `\n` and `\r`. | |
| //! This allows parsing sequences of one or more arbitrarily formatted JSON values, including | |
| //! but not limited to newline-delimited JSON. |
arrow-json/src/reader/mod.rs
Outdated
| } | ||
| } | ||
|
|
||
| /// Create a new [`ReaderBuilder`] with the provided [`FieldRef`] |
Contributor
There was a problem hiding this comment.
Suggested change
| /// Create a new [`ReaderBuilder`] with the provided [`FieldRef`] | |
| /// Create a new [`ReaderBuilder`] that will parse JSON values with a root schema of [`FieldRef`]. |
Perhaps we can add a note in new() that says it does require the root to be an object like {..}.
I wonder if new_from_field might be a more descriptive name (as this isn't making a new Field, it is making a new reader that reads data with the type on the field
| false, | ||
| )?; | ||
| let (data_type, nullable) = match self.is_field { | ||
| false => (DataType::Struct(self.schema.fields.clone()), false), |
Contributor
There was a problem hiding this comment.
why not allow null root fields with structs?
Contributor
Author
There was a problem hiding this comment.
Because RecordBatch can't support nulls at the root level
| elements: Vec<TapeElement>, | ||
|
|
||
| num_rows: usize, | ||
| cur_row: usize, |
Contributor
There was a problem hiding this comment.
Suggested change
| cur_row: usize, | |
| /// logical row being decoded | |
| cur_row: usize, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #4905
Rationale for this change
We should support decoding JSON payloads that don't have an object as the root.
What changes are included in this PR?
Are there any user-facing changes?