Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Fix issue with nested lists
Browse files Browse the repository at this point in the history
  • Loading branch information
AnIrishDuck committed Oct 13, 2022
1 parent 19f739e commit 1e5cf55
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions src/io/json/read/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,35 +572,31 @@ pub fn deserialize(json: &Value, data_type: DataType) -> Result<Box<dyn Array>,
}

fn allocate_array(f: &Field) -> Box<dyn MutableArray> {
fn allocate_inner(f: &Field) -> Box<dyn MutableArray> {
match f.data_type() {
DataType::Int8 => Box::new(MutablePrimitiveArray::<i8>::new()),
DataType::Int16 => Box::new(MutablePrimitiveArray::<i16>::new()),
DataType::Int32 => Box::new(MutablePrimitiveArray::<i32>::new()),
DataType::Int64 => Box::new(MutablePrimitiveArray::<i64>::new()),
DataType::UInt8 => Box::new(MutablePrimitiveArray::<u8>::new()),
DataType::UInt16 => Box::new(MutablePrimitiveArray::<u16>::new()),
DataType::UInt32 => Box::new(MutablePrimitiveArray::<u32>::new()),
DataType::UInt64 => Box::new(MutablePrimitiveArray::<u64>::new()),
DataType::Float16 => Box::new(MutablePrimitiveArray::<f16>::new()),
DataType::Float32 => Box::new(MutablePrimitiveArray::<f32>::new()),
DataType::Float64 => Box::new(MutablePrimitiveArray::<f64>::new()),
DataType::List(..) => allocate_array(f),
DataType::FixedSizeList(..) => allocate_array(f),
_ => todo!(),
}
}
match f.data_type() {
DataType::List(inner) => Box::new(MutableListArray::<i32, _>::new_from(
DataType::Int8 => Box::new(MutablePrimitiveArray::<i8>::new()),
DataType::Int16 => Box::new(MutablePrimitiveArray::<i16>::new()),
DataType::Int32 => Box::new(MutablePrimitiveArray::<i32>::new()),
DataType::Int64 => Box::new(MutablePrimitiveArray::<i64>::new()),
DataType::UInt8 => Box::new(MutablePrimitiveArray::<u8>::new()),
DataType::UInt16 => Box::new(MutablePrimitiveArray::<u16>::new()),
DataType::UInt32 => Box::new(MutablePrimitiveArray::<u32>::new()),
DataType::UInt64 => Box::new(MutablePrimitiveArray::<u64>::new()),
DataType::Float16 => Box::new(MutablePrimitiveArray::<f16>::new()),
DataType::Float32 => Box::new(MutablePrimitiveArray::<f32>::new()),
DataType::Float64 => Box::new(MutablePrimitiveArray::<f64>::new()),
DataType::FixedSizeList(inner, size) => Box::new(MutableFixedSizeListArray::<_>::new_from(
allocate_array(inner),
f.data_type().clone(),
0,
)),
DataType::FixedSizeList(child, size) => Box::new(MutableFixedSizeListArray::<_>::new_from(
allocate_inner(child),
f.data_type().clone(),
*size,
)),
DataType::List(inner) => match inner.data_type() {
DataType::List(_) => Box::new(MutableListArray::<i32, _>::new_from(
allocate_array(inner),
inner.data_type().clone(),
0,
)),
_ => allocate_array(inner),
},
_ => todo!(),
}
}
Expand Down

0 comments on commit 1e5cf55

Please sign in to comment.