alamb commented on code in PR #5622:
URL: https://github.com/apache/arrow-rs/pull/5622#discussion_r1559500899
##########
arrow-json/src/writer/encoder.rs:
##########
@@ -443,3 +448,17 @@ impl<'a> Encoder for MapEncoder<'a> {
out.push(b'}');
}
}
+
+struct FixedSizeBinaryEncoder(FixedSizeBinaryArray);
+
+impl Encoder for FixedSizeBinaryEncoder {
+ fn encode(&mut self, idx: usize, out: &mut Vec<u8>) {
+ let v = self.0.value(idx);
Review Comment:
I think this needs to check `is_valid` before serializing (I think you'll
see the need when testing for null)
##########
arrow-json/src/writer.rs:
##########
@@ -2137,4 +2139,46 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn test_writer_fixed_size_binary() {
+ // set up schema:
+ let size = 11;
+ let schema = SchemaRef::new(Schema::new(vec![Field::new(
+ "bytes",
+ DataType::FixedSizeBinary(size),
+ false,
+ )]));
+
+ // build record batch:
+ let mut builder = FixedSizeBinaryBuilder::new(size);
+ let values = [b"hello world", b"summer rain"];
+ for v in values {
+ builder.append_value(v).unwrap();
+ }
Review Comment:
Can you also please test serializing NULLs by adding a null in the input?
You can do so with`builder.append_null()`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]