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

Function writer_string_reader_nullable_with_alias

arrow-avro/src/reader/mod.rs:2004–2035  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2002
2003 #[test]
2004 fn writer_string_reader_nullable_with_alias() -> Result<(), Box<dyn std::error::Error>> {
2005 let writer_schema = Schema::new(vec![
2006 Field::new("id", DataType::Int64, false),
2007 Field::new("name", DataType::Utf8, false),
2008 ]);
2009 let batch = RecordBatch::try_new(
2010 Arc::new(writer_schema.clone()),
2011 vec![
2012 Arc::new(Int64Array::from(vec![1, 2])) as ArrayRef,
2013 Arc::new(StringArray::from(vec!["a", "b"])) as ArrayRef,
2014 ],
2015 )?;
2016 let bytes = write_ocf(&writer_schema, &[batch]);
2017 let reader_json = r#"
2018 {
2019 "type": "record",
2020 "name": "topLevelRecord",
2021 "fields": [
2022 { "name": "id", "type": "long" },
2023 { "name": "full_name", "type": ["null","string"], "aliases": ["name"], "default": null },
2024 { "name": "is_active", "type": "boolean", "default": true }
2025 ]
2026 }"#;
2027 let mut reader = ReaderBuilder::new()
2028 .with_reader_schema(AvroSchema::new(reader_json.to_string()))
2029 .build(Cursor::new(bytes))?;
2030 let out = reader.next().unwrap()?;
2031 let full_name = out.column(1).as_string::<i32>();
2032 assert_eq!(full_name.value(0), "a");
2033 assert_eq!(full_name.value(1), "b");
2034 Ok(())
2035 }
2036
2037 #[test]
2038 fn writer_string_reader_string_null_order_second() -> Result<(), Box<dyn std::error::Error>> {

Callers

nothing calls this directly

Calls 7

try_newFunction · 0.85
write_ocfFunction · 0.85
cloneMethod · 0.45
buildMethod · 0.45
with_reader_schemaMethod · 0.45
nextMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected