MCPcopy Create free account
hub / github.com/apache/arrow-rs / encode_rows_nullable_column

Function encode_rows_nullable_column

arrow-avro/src/writer/encoder.rs:3807–3835  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3805
3806 #[test]
3807 fn encode_rows_nullable_column() {
3808 let schema = ArrowSchema::new(vec![Field::new("x", DataType::Int32, true)]);
3809 let arr = Int32Array::from(vec![Some(1), None, Some(3)]);
3810 let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(arr)]).unwrap();
3811 let encoder = RecordEncoder {
3812 columns: vec![FieldBinding {
3813 arrow_index: 0,
3814 nullability: Some(Nullability::NullFirst),
3815 plan: FieldPlan::Scalar,
3816 }],
3817 prefix: None,
3818 };
3819 let mut out = BytesMut::new();
3820 let mut offsets: Vec<usize> = vec![0];
3821 encoder
3822 .encode_rows(&batch, 16, &mut out, &mut offsets)
3823 .unwrap();
3824 assert_eq!(offsets.len(), 4);
3825 let mut expected_row0 = Vec::new();
3826 expected_row0.extend(avro_long_bytes(1)); // union branch for value
3827 expected_row0.extend(avro_long_bytes(1)); // value
3828 assert_bytes_eq(row_slice(&out, &offsets, 0), &expected_row0);
3829 let expected_row1 = avro_long_bytes(0); // union branch for null
3830 assert_bytes_eq(row_slice(&out, &offsets, 1), &expected_row1);
3831 let mut expected_row2 = Vec::new();
3832 expected_row2.extend(avro_long_bytes(1)); // union branch for value
3833 expected_row2.extend(avro_long_bytes(3)); // value
3834 assert_bytes_eq(row_slice(&out, &offsets, 2), &expected_row2);
3835 }
3836
3837 #[test]
3838 fn encode_prefix_write_error() {

Callers

nothing calls this directly

Calls 7

try_newFunction · 0.85
avro_long_bytesFunction · 0.85
assert_bytes_eqFunction · 0.85
row_sliceFunction · 0.85
encode_rowsMethod · 0.80
cloneMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected