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

Commit

Permalink
Fixed error in writing list<struct<..>>
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed May 28, 2022
1 parent 7cc874f commit 35cfee1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/io/parquet/write/nested/rep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn iter<'a>(nested: &'a [Nested]) -> Vec<Box<dyn DebugIter + 'a>> {
Some(Box::new(to_length(nested.offsets)) as Box<dyn DebugIter>)
}
Nested::Struct(_, _, length) => {
Some(Box::new(std::iter::repeat(0usize).take(*length)) as Box<dyn DebugIter>)
Some(Box::new(std::iter::repeat(1usize).take(*length)) as Box<dyn DebugIter>)
}
})
.collect()
Expand Down Expand Up @@ -202,4 +202,25 @@ mod tests {

test(nested, expected)
}

#[test]
fn list_of_struct() {
/*
[
[{"a": "b"}],[{"a": "c"}]
]
*/
let nested = vec![
Nested::List(ListNested {
is_optional: true,
offsets: &[0i32, 1, 2],
validity: None,
}),
Nested::Struct(None, true, 2),
Nested::Primitive(None, true, 2),
];
let expected = vec![0, 0];

test(nested, expected)
}
}

0 comments on commit 35cfee1

Please sign in to comment.