svenwb commented on a change in pull request #7379:
URL: https://github.com/apache/arrow/pull/7379#discussion_r437995071
##########
File path: rust/arrow/src/json/reader.rs
##########
@@ -448,42 +453,55 @@ impl<R: Read> Reader<R> {
let mut builder = ListBuilder::new(values_builder);
for row in rows {
if let Some(value) = row.get(field.name()) {
- // value can be an array or a scalar
- let vals: Vec<Option<String>> = if let
Value::String(v) = value {
- vec![Some(v.to_string())]
- } else if let Value::Array(n) = value {
- n.iter().map(|v: &Value| {
- if v.is_string() {
-
Some(v.as_str().unwrap().to_string())
- } else if v.is_array() ||
v.is_object() {
- // implicitly drop nested
values
- // TODO support
deep-nesting
- None
- } else {
- Some(v.to_string())
- }
- }).collect()
- } else if let Value::Null = value {
- vec![None]
- } else if !value.is_object() {
- vec![Some(value.to_string())]
+ // value can be an array or a scalar
+ let vals: Vec<Option<String>> = if let
Value::String(v) = value {
+ vec![Some(v.to_string())]
+ } else if let Value::Array(n) = value {
+ n.iter().map(|v: &Value| {
+ if v.is_string() {
+
Some(v.as_str().unwrap().to_string())
+ } else if v.is_array() ||
v.is_object() {
+ // implicitly drop nested
values
+ // TODO support deep-nesting
+ None
+ } else {
+ Some(v.to_string())
+ }
+ }).collect()
+ } else if let Value::Null = value {
+ vec![None]
+ } else if !value.is_object() {
+ vec![Some(value.to_string())]
+ } else {
+ return Err(ArrowError::JsonError("Only
scalars are currently supported in JSON arrays".to_string()));
+ };
Review comment:
As this code was only changed by the formatter I would suggest to make
this refactoring in different PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]