MCPcopy Create free account
hub / github.com/apache/datafusion / fmt

Method fmt

datafusion/common/src/scalar/mod.rs:5352–5526  ·  view source on GitHub ↗
(&self, f: &mut fmt::Formatter)

Source from the content-addressed store, hash-verified

5350// Panics if there is an error when creating a visual representation of columns via `arrow::util::pretty`
5351impl fmt::Display for ScalarValue {
5352 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5353 match self {
5354 ScalarValue::Decimal32(v, p, s) => {
5355 write!(f, "{v:?},{p:?},{s:?}")?;
5356 }
5357 ScalarValue::Decimal64(v, p, s) => {
5358 write!(f, "{v:?},{p:?},{s:?}")?;
5359 }
5360 ScalarValue::Decimal128(v, p, s) => {
5361 write!(f, "{v:?},{p:?},{s:?}")?;
5362 }
5363 ScalarValue::Decimal256(v, p, s) => {
5364 write!(f, "{v:?},{p:?},{s:?}")?;
5365 }
5366 ScalarValue::Boolean(e) => format_option!(f, e)?,
5367 ScalarValue::Float16(e) => format_option!(f, e)?,
5368 ScalarValue::Float32(e) => format_option!(f, e)?,
5369 ScalarValue::Float64(e) => format_option!(f, e)?,
5370 ScalarValue::Int8(e) => format_option!(f, e)?,
5371 ScalarValue::Int16(e) => format_option!(f, e)?,
5372 ScalarValue::Int32(e) => format_option!(f, e)?,
5373 ScalarValue::Int64(e) => format_option!(f, e)?,
5374 ScalarValue::UInt8(e) => format_option!(f, e)?,
5375 ScalarValue::UInt16(e) => format_option!(f, e)?,
5376 ScalarValue::UInt32(e) => format_option!(f, e)?,
5377 ScalarValue::UInt64(e) => format_option!(f, e)?,
5378 ScalarValue::TimestampSecond(e, _) => format_option!(f, e)?,
5379 ScalarValue::TimestampMillisecond(e, _) => format_option!(f, e)?,
5380 ScalarValue::TimestampMicrosecond(e, _) => format_option!(f, e)?,
5381 ScalarValue::TimestampNanosecond(e, _) => format_option!(f, e)?,
5382 ScalarValue::Utf8(e)
5383 | ScalarValue::LargeUtf8(e)
5384 | ScalarValue::Utf8View(e) => format_option!(f, e)?,
5385 ScalarValue::Binary(e)
5386 | ScalarValue::FixedSizeBinary(_, e)
5387 | ScalarValue::LargeBinary(e)
5388 | ScalarValue::BinaryView(e) => match e {
5389 Some(bytes) => {
5390 // print up to first 10 bytes, with trailing ... if needed
5391 const HEX_CHARS_UPPER: &[u8; 16] = b"0123456789ABCDEF";
5392 for b in bytes.iter().take(10) {
5393 f.write_char(HEX_CHARS_UPPER[(b >> 4) as usize] as char)?;
5394 f.write_char(HEX_CHARS_UPPER[(b & 0x0f) as usize] as char)?;
5395 }
5396 if bytes.len() > 10 {
5397 write!(f, "...")?;
5398 }
5399 }
5400 None => write!(f, "NULL")?,
5401 },
5402 ScalarValue::List(arr) => fmt_list(arr.as_ref(), f)?,
5403 ScalarValue::LargeList(arr) => fmt_list(arr.as_ref(), f)?,
5404 ScalarValue::FixedSizeList(arr) => fmt_list(arr.as_ref(), f)?,
5405 ScalarValue::ListView(arr) => fmt_list(arr.as_ref(), f)?,
5406 ScalarValue::LargeListView(arr) => fmt_list(arr.as_ref(), f)?,
5407 ScalarValue::Date32(e) => format_option!(
5408 f,
5409 e.map(|v| {

Callers

nothing calls this directly

Calls 11

fmt_listFunction · 0.85
fmt_binaryFunction · 0.85
write_charMethod · 0.80
null_countMethod · 0.80
columnsMethod · 0.80
takeMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
as_refMethod · 0.45
fieldsMethod · 0.45
nullsMethod · 0.45

Tested by

no test coverage detected