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

Function test_parse_string_view_multi_column

arrow-csv/src/reader/mod.rs:2823–2855  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2821
2822 #[test]
2823 fn test_parse_string_view_multi_column() {
2824 let csv = ["foo,", ",something_cannot_be_inlined", "foobarfoobar,bar"].join("\n");
2825 let schema = Arc::new(Schema::new(vec![
2826 Field::new("c1", DataType::Utf8View, true),
2827 Field::new("c2", DataType::Utf8View, true),
2828 ]));
2829
2830 let mut decoder = ReaderBuilder::new(schema).build_decoder();
2831
2832 let decoded = decoder.decode(csv.as_bytes()).unwrap();
2833 assert_eq!(decoded, csv.len());
2834 decoder.decode(&[]).unwrap();
2835
2836 let batch = decoder.flush().unwrap().unwrap();
2837 assert_eq!(batch.num_columns(), 2);
2838 assert_eq!(batch.num_rows(), 3);
2839 let c1 = batch.column(0).as_string_view();
2840 let c2 = batch.column(1).as_string_view();
2841 assert_eq!(c1.data_type(), &DataType::Utf8View);
2842 assert_eq!(c2.data_type(), &DataType::Utf8View);
2843
2844 assert!(!c1.is_null(0));
2845 assert!(c1.is_null(1));
2846 assert!(!c1.is_null(2));
2847 assert_eq!(c1.value(0), "foo");
2848 assert_eq!(c1.value(2), "foobarfoobar");
2849
2850 assert!(c2.is_null(0));
2851 assert!(!c2.is_null(1));
2852 assert!(!c2.is_null(2));
2853 assert_eq!(c2.value(1), "something_cannot_be_inlined");
2854 assert_eq!(c2.value(2), "bar");
2855 }
2856}

Callers

nothing calls this directly

Calls 7

joinMethod · 0.80
as_string_viewMethod · 0.80
build_decoderMethod · 0.45
decodeMethod · 0.45
as_bytesMethod · 0.45
flushMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected