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

Method create_array_formatter

arrow-cast/src/pretty.rs:1255–1284  ·  view source on GitHub ↗
(
            &self,
            array: &'formatter dyn Array,
            options: &FormatOptions<'formatter>,
            field: Option<&'formatter Field>,
        )

Source from the content-addressed store, hash-verified

1253
1254 impl ArrayFormatterFactory for TestFormatters {
1255 fn create_array_formatter<'formatter>(
1256 &self,
1257 array: &'formatter dyn Array,
1258 options: &FormatOptions<'formatter>,
1259 field: Option<&'formatter Field>,
1260 ) -> Result<Option<ArrayFormatter<'formatter>>, ArrowError> {
1261 if field
1262 .map(|f| f.extension_type_name() == Some("my_money"))
1263 .unwrap_or(false)
1264 {
1265 // We assume that my_money always is an Int32.
1266 let array = array.as_primitive();
1267 let display_index = Box::new(MyMoneyFormatter {
1268 array,
1269 options: options.clone(),
1270 });
1271 return Ok(Some(ArrayFormatter::new(display_index, options.safe())));
1272 }
1273
1274 if array.data_type() == &DataType::Int32 {
1275 let array = array.as_primitive();
1276 let display_index = Box::new(MyInt32Formatter {
1277 array,
1278 options: options.clone(),
1279 });
1280 return Ok(Some(ArrayFormatter::new(display_index, options.safe())));
1281 }
1282
1283 Ok(None)
1284 }
1285 }
1286
1287 /// A format that will append a "€" sign to the end of the Int32 values.

Callers 2

make_array_formatterFunction · 0.80
create_columnFunction · 0.80

Calls 5

extension_type_nameMethod · 0.80
as_primitiveMethod · 0.80
safeMethod · 0.80
cloneMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected