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

Function get_format_string

arrow-schema/src/ffi.rs:712–788  ·  view source on GitHub ↗
(dtype: &DataType)

Source from the content-addressed store, hash-verified

710}
711
712fn get_format_string(dtype: &DataType) -> Result<Cow<'static, str>, ArrowError> {
713 match dtype {
714 DataType::Null => Ok("n".into()),
715 DataType::Boolean => Ok("b".into()),
716 DataType::Int8 => Ok("c".into()),
717 DataType::UInt8 => Ok("C".into()),
718 DataType::Int16 => Ok("s".into()),
719 DataType::UInt16 => Ok("S".into()),
720 DataType::Int32 => Ok("i".into()),
721 DataType::UInt32 => Ok("I".into()),
722 DataType::Int64 => Ok("l".into()),
723 DataType::UInt64 => Ok("L".into()),
724 DataType::Float16 => Ok("e".into()),
725 DataType::Float32 => Ok("f".into()),
726 DataType::Float64 => Ok("g".into()),
727 DataType::BinaryView => Ok("vz".into()),
728 DataType::Binary => Ok("z".into()),
729 DataType::LargeBinary => Ok("Z".into()),
730 DataType::Utf8View => Ok("vu".into()),
731 DataType::Utf8 => Ok("u".into()),
732 DataType::LargeUtf8 => Ok("U".into()),
733 DataType::FixedSizeBinary(num_bytes) => Ok(Cow::Owned(format!("w:{num_bytes}"))),
734 DataType::FixedSizeList(_, num_elems) => Ok(Cow::Owned(format!("+w:{num_elems}"))),
735 DataType::Decimal32(precision, scale) => {
736 Ok(Cow::Owned(format!("d:{precision},{scale},32")))
737 }
738 DataType::Decimal64(precision, scale) => {
739 Ok(Cow::Owned(format!("d:{precision},{scale},64")))
740 }
741 DataType::Decimal128(precision, scale) => Ok(Cow::Owned(format!("d:{precision},{scale}"))),
742 DataType::Decimal256(precision, scale) => {
743 Ok(Cow::Owned(format!("d:{precision},{scale},256")))
744 }
745 DataType::Date32 => Ok("tdD".into()),
746 DataType::Date64 => Ok("tdm".into()),
747 DataType::Time32(TimeUnit::Second) => Ok("tts".into()),
748 DataType::Time32(TimeUnit::Millisecond) => Ok("ttm".into()),
749 DataType::Time64(TimeUnit::Microsecond) => Ok("ttu".into()),
750 DataType::Time64(TimeUnit::Nanosecond) => Ok("ttn".into()),
751 DataType::Timestamp(TimeUnit::Second, None) => Ok("tss:".into()),
752 DataType::Timestamp(TimeUnit::Millisecond, None) => Ok("tsm:".into()),
753 DataType::Timestamp(TimeUnit::Microsecond, None) => Ok("tsu:".into()),
754 DataType::Timestamp(TimeUnit::Nanosecond, None) => Ok("tsn:".into()),
755 DataType::Timestamp(TimeUnit::Second, Some(tz)) => Ok(Cow::Owned(format!("tss:{tz}"))),
756 DataType::Timestamp(TimeUnit::Millisecond, Some(tz)) => Ok(Cow::Owned(format!("tsm:{tz}"))),
757 DataType::Timestamp(TimeUnit::Microsecond, Some(tz)) => Ok(Cow::Owned(format!("tsu:{tz}"))),
758 DataType::Timestamp(TimeUnit::Nanosecond, Some(tz)) => Ok(Cow::Owned(format!("tsn:{tz}"))),
759 DataType::Duration(TimeUnit::Second) => Ok("tDs".into()),
760 DataType::Duration(TimeUnit::Millisecond) => Ok("tDm".into()),
761 DataType::Duration(TimeUnit::Microsecond) => Ok("tDu".into()),
762 DataType::Duration(TimeUnit::Nanosecond) => Ok("tDn".into()),
763 DataType::Interval(IntervalUnit::YearMonth) => Ok("tiM".into()),
764 DataType::Interval(IntervalUnit::DayTime) => Ok("tiD".into()),
765 DataType::Interval(IntervalUnit::MonthDayNano) => Ok("tin".into()),
766 DataType::List(_) => Ok("+l".into()),
767 DataType::LargeList(_) => Ok("+L".into()),
768 DataType::ListView(_) => Ok("+vl".into()),
769 DataType::LargeListView(_) => Ok("+vL".into()),

Callers 1

try_fromMethod · 0.85

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected