From ab3a2545280472d17d16e9f7e5e634532ee243bc Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Fri, 6 Dec 2024 13:41:32 -0700 Subject: [PATCH 1/6] add cast_decimal bench --- arrow-cast/Cargo.toml | 4 +++ arrow-cast/benches/cast_decimal.rs | 45 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 arrow-cast/benches/cast_decimal.rs diff --git a/arrow-cast/Cargo.toml b/arrow-cast/Cargo.toml index 4046f5226094..a62e25eb9a57 100644 --- a/arrow-cast/Cargo.toml +++ b/arrow-cast/Cargo.toml @@ -77,3 +77,7 @@ harness = false [[bench]] name = "parse_decimal" harness = false + +[[bench]] +name = "cast_decimal" +harness = false diff --git a/arrow-cast/benches/cast_decimal.rs b/arrow-cast/benches/cast_decimal.rs new file mode 100644 index 000000000000..a7d035ab26fc --- /dev/null +++ b/arrow-cast/benches/cast_decimal.rs @@ -0,0 +1,45 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use arrow_array::{ArrayRef, Decimal128Array}; +use arrow_cast::{cast_with_options, CastOptions}; +use arrow_schema::DataType; +use criterion::*; +use std::sync::Arc; + +fn criterion_benchmark(c: &mut Criterion) { + let decimals: ArrayRef = Arc::new( + Decimal128Array::from(vec![ + 0, + 1234, + -1234, + 1234567, + -1234567, + i128::MAX, + i128::MIN, + ]) + .with_precision_and_scale(24, 2).unwrap(), + ); + let options = CastOptions::default(); + let d = black_box(decimals); + c.bench_function("cast_decimal", |b| { + b.iter(|| cast_with_options(&d, &DataType::Decimal128(6, 2), &options).unwrap()); + }); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); From 2fa5b13941bd8c9f18ffb4ea3d31039080cf0d89 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Fri, 6 Dec 2024 13:53:57 -0700 Subject: [PATCH 2/6] format --- arrow-cast/benches/cast_decimal.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arrow-cast/benches/cast_decimal.rs b/arrow-cast/benches/cast_decimal.rs index a7d035ab26fc..cc85fc171137 100644 --- a/arrow-cast/benches/cast_decimal.rs +++ b/arrow-cast/benches/cast_decimal.rs @@ -32,7 +32,8 @@ fn criterion_benchmark(c: &mut Criterion) { i128::MAX, i128::MIN, ]) - .with_precision_and_scale(24, 2).unwrap(), + .with_precision_and_scale(24, 2) + .unwrap(), ); let options = CastOptions::default(); let d = black_box(decimals); From 3c8e1b79962d74e7680505e2027f97b9d26974de Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Fri, 6 Dec 2024 16:27:36 -0700 Subject: [PATCH 3/6] save --- arrow-schema/Cargo.toml | 5 ++ arrow-schema/benches/ffi.rs | 38 +++++++++++++ arrow-schema/src/ffi.rs | 107 ++++++++++++++++++------------------ 3 files changed, 98 insertions(+), 52 deletions(-) create mode 100644 arrow-schema/benches/ffi.rs diff --git a/arrow-schema/Cargo.toml b/arrow-schema/Cargo.toml index 628d4a683cac..4b5e7a22e263 100644 --- a/arrow-schema/Cargo.toml +++ b/arrow-schema/Cargo.toml @@ -36,6 +36,7 @@ bench = false [dependencies] serde = { version = "1.0", default-features = false, features = ["derive", "std", "rc"], optional = true } bitflags = { version = "2.0.0", default-features = false, optional = true } +criterion = "0.5.1" [features] # Enable ffi support @@ -47,3 +48,7 @@ features = ["ffi"] [dev-dependencies] serde_json = "1.0" bincode = { version = "1.3.3", default-features = false } + +[[bench]] +name = "ffi" +harness = false \ No newline at end of file diff --git a/arrow-schema/benches/ffi.rs b/arrow-schema/benches/ffi.rs new file mode 100644 index 000000000000..1285acb883ea --- /dev/null +++ b/arrow-schema/benches/ffi.rs @@ -0,0 +1,38 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use arrow_schema::ffi::FFI_ArrowSchema; +use arrow_schema::{DataType, Field}; +use criterion::*; +use std::sync::Arc; + +fn criterion_benchmark(c: &mut Criterion) { + let fields = vec![ + Arc::new(Field::new("c1", DataType::Utf8, false)), + Arc::new(Field::new("c2", DataType::Utf8, false)), + Arc::new(Field::new("c3", DataType::Utf8, false)), + Arc::new(Field::new("c4", DataType::Utf8, false)), + Arc::new(Field::new("c5", DataType::Utf8, false)), + ]; + let data_type = DataType::Struct(fields.into()); + c.bench_function("ffi_arrow_schema_try_from", |b| { + b.iter(|| FFI_ArrowSchema::try_from(&data_type)); + }); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/arrow-schema/src/ffi.rs b/arrow-schema/src/ffi.rs index 70650d769cf6..c0fc8b25d85c 100644 --- a/arrow-schema/src/ffi.rs +++ b/arrow-schema/src/ffi.rs @@ -38,6 +38,7 @@ use crate::{ ArrowError, DataType, Field, FieldRef, IntervalUnit, Schema, TimeUnit, UnionFields, UnionMode, }; use bitflags::bitflags; +use std::borrow::Cow; use std::sync::Arc; use std::{ collections::HashMap, @@ -685,57 +686,59 @@ impl TryFrom<&DataType> for FFI_ArrowSchema { } } -fn get_format_string(dtype: &DataType) -> Result { +fn get_format_string(dtype: &DataType) -> Result, ArrowError> { match dtype { - DataType::Null => Ok("n".to_string()), - DataType::Boolean => Ok("b".to_string()), - DataType::Int8 => Ok("c".to_string()), - DataType::UInt8 => Ok("C".to_string()), - DataType::Int16 => Ok("s".to_string()), - DataType::UInt16 => Ok("S".to_string()), - DataType::Int32 => Ok("i".to_string()), - DataType::UInt32 => Ok("I".to_string()), - DataType::Int64 => Ok("l".to_string()), - DataType::UInt64 => Ok("L".to_string()), - DataType::Float16 => Ok("e".to_string()), - DataType::Float32 => Ok("f".to_string()), - DataType::Float64 => Ok("g".to_string()), - DataType::BinaryView => Ok("vz".to_string()), - DataType::Binary => Ok("z".to_string()), - DataType::LargeBinary => Ok("Z".to_string()), - DataType::Utf8View => Ok("vu".to_string()), - DataType::Utf8 => Ok("u".to_string()), - DataType::LargeUtf8 => Ok("U".to_string()), - DataType::FixedSizeBinary(num_bytes) => Ok(format!("w:{num_bytes}")), - DataType::FixedSizeList(_, num_elems) => Ok(format!("+w:{num_elems}")), - DataType::Decimal128(precision, scale) => Ok(format!("d:{precision},{scale}")), - DataType::Decimal256(precision, scale) => Ok(format!("d:{precision},{scale},256")), - DataType::Date32 => Ok("tdD".to_string()), - DataType::Date64 => Ok("tdm".to_string()), - DataType::Time32(TimeUnit::Second) => Ok("tts".to_string()), - DataType::Time32(TimeUnit::Millisecond) => Ok("ttm".to_string()), - DataType::Time64(TimeUnit::Microsecond) => Ok("ttu".to_string()), - DataType::Time64(TimeUnit::Nanosecond) => Ok("ttn".to_string()), - DataType::Timestamp(TimeUnit::Second, None) => Ok("tss:".to_string()), - DataType::Timestamp(TimeUnit::Millisecond, None) => Ok("tsm:".to_string()), - DataType::Timestamp(TimeUnit::Microsecond, None) => Ok("tsu:".to_string()), - DataType::Timestamp(TimeUnit::Nanosecond, None) => Ok("tsn:".to_string()), - DataType::Timestamp(TimeUnit::Second, Some(tz)) => Ok(format!("tss:{tz}")), - DataType::Timestamp(TimeUnit::Millisecond, Some(tz)) => Ok(format!("tsm:{tz}")), - DataType::Timestamp(TimeUnit::Microsecond, Some(tz)) => Ok(format!("tsu:{tz}")), - DataType::Timestamp(TimeUnit::Nanosecond, Some(tz)) => Ok(format!("tsn:{tz}")), - DataType::Duration(TimeUnit::Second) => Ok("tDs".to_string()), - DataType::Duration(TimeUnit::Millisecond) => Ok("tDm".to_string()), - DataType::Duration(TimeUnit::Microsecond) => Ok("tDu".to_string()), - DataType::Duration(TimeUnit::Nanosecond) => Ok("tDn".to_string()), - DataType::Interval(IntervalUnit::YearMonth) => Ok("tiM".to_string()), - DataType::Interval(IntervalUnit::DayTime) => Ok("tiD".to_string()), - DataType::Interval(IntervalUnit::MonthDayNano) => Ok("tin".to_string()), - DataType::List(_) => Ok("+l".to_string()), - DataType::LargeList(_) => Ok("+L".to_string()), - DataType::Struct(_) => Ok("+s".to_string()), - DataType::Map(_, _) => Ok("+m".to_string()), - DataType::RunEndEncoded(_, _) => Ok("+r".to_string()), + DataType::Null => Ok(Cow::Borrowed("n")), + DataType::Boolean => Ok(Cow::Borrowed("b")), + DataType::Int8 => Ok(Cow::Borrowed("c")), + DataType::UInt8 => Ok(Cow::Borrowed("C")), + DataType::Int16 => Ok(Cow::Borrowed("s")), + DataType::UInt16 => Ok(Cow::Borrowed("S")), + DataType::Int32 => Ok(Cow::Borrowed("i")), + DataType::UInt32 => Ok(Cow::Borrowed("I")), + DataType::Int64 => Ok(Cow::Borrowed("l")), + DataType::UInt64 => Ok(Cow::Borrowed("L")), + DataType::Float16 => Ok(Cow::Borrowed("e")), + DataType::Float32 => Ok(Cow::Borrowed("f")), + DataType::Float64 => Ok(Cow::Borrowed("g")), + DataType::BinaryView => Ok(Cow::Borrowed("vz")), + DataType::Binary => Ok(Cow::Borrowed("z")), + DataType::LargeBinary => Ok(Cow::Borrowed("Z")), + DataType::Utf8View => Ok(Cow::Borrowed("vu")), + DataType::Utf8 => Ok(Cow::Borrowed("u")), + DataType::LargeUtf8 => Ok(Cow::Borrowed("U")), + DataType::FixedSizeBinary(num_bytes) => Ok(Cow::Owned(format!("w:{num_bytes}"))), + DataType::FixedSizeList(_, num_elems) => Ok(Cow::Owned(format!("+w:{num_elems}"))), + DataType::Decimal128(precision, scale) => Ok(Cow::Owned(format!("d:{precision},{scale}"))), + DataType::Decimal256(precision, scale) => { + Ok(Cow::Owned(format!("d:{precision},{scale},256"))) + } + DataType::Date32 => Ok(Cow::Borrowed("tdD")), + DataType::Date64 => Ok(Cow::Borrowed("tdm")), + DataType::Time32(TimeUnit::Second) => Ok(Cow::Borrowed("tts")), + DataType::Time32(TimeUnit::Millisecond) => Ok(Cow::Borrowed("ttm")), + DataType::Time64(TimeUnit::Microsecond) => Ok(Cow::Borrowed("ttu")), + DataType::Time64(TimeUnit::Nanosecond) => Ok(Cow::Borrowed("ttn")), + DataType::Timestamp(TimeUnit::Second, None) => Ok(Cow::Borrowed("tss:")), + DataType::Timestamp(TimeUnit::Millisecond, None) => Ok(Cow::Borrowed("tsm:")), + DataType::Timestamp(TimeUnit::Microsecond, None) => Ok(Cow::Borrowed("tsu:")), + DataType::Timestamp(TimeUnit::Nanosecond, None) => Ok(Cow::Borrowed("tsn:")), + DataType::Timestamp(TimeUnit::Second, Some(tz)) => Ok(Cow::Owned(format!("tss:{tz}"))), + DataType::Timestamp(TimeUnit::Millisecond, Some(tz)) => Ok(Cow::Owned(format!("tsm:{tz}"))), + DataType::Timestamp(TimeUnit::Microsecond, Some(tz)) => Ok(Cow::Owned(format!("tsu:{tz}"))), + DataType::Timestamp(TimeUnit::Nanosecond, Some(tz)) => Ok(Cow::Owned(format!("tsn:{tz}"))), + DataType::Duration(TimeUnit::Second) => Ok(Cow::Borrowed("tDs")), + DataType::Duration(TimeUnit::Millisecond) => Ok(Cow::Borrowed("tDm")), + DataType::Duration(TimeUnit::Microsecond) => Ok(Cow::Borrowed("tDu")), + DataType::Duration(TimeUnit::Nanosecond) => Ok(Cow::Borrowed("tDn")), + DataType::Interval(IntervalUnit::YearMonth) => Ok(Cow::Borrowed("tiM")), + DataType::Interval(IntervalUnit::DayTime) => Ok(Cow::Borrowed("tiD")), + DataType::Interval(IntervalUnit::MonthDayNano) => Ok(Cow::Borrowed("tin")), + DataType::List(_) => Ok(Cow::Borrowed("+l")), + DataType::LargeList(_) => Ok(Cow::Borrowed("+L")), + DataType::Struct(_) => Ok(Cow::Borrowed("+s")), + DataType::Map(_, _) => Ok(Cow::Borrowed("+m")), + DataType::RunEndEncoded(_, _) => Ok(Cow::Borrowed("+r")), DataType::Dictionary(key_data_type, _) => get_format_string(key_data_type), DataType::Union(fields, mode) => { let formats = fields @@ -743,8 +746,8 @@ fn get_format_string(dtype: &DataType) -> Result { .map(|(t, _)| t.to_string()) .collect::>(); match mode { - UnionMode::Dense => Ok(format!("{}:{}", "+ud", formats.join(","))), - UnionMode::Sparse => Ok(format!("{}:{}", "+us", formats.join(","))), + UnionMode::Dense => Ok(Cow::Owned(format!("{}:{}", "+ud", formats.join(",")))), + UnionMode::Sparse => Ok(Cow::Owned(format!("{}:{}", "+us", formats.join(",")))), } } other => Err(ArrowError::CDataInterface(format!( From 51a6d66dbbdc6d8ac4b389318f633b9856f52f59 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Fri, 6 Dec 2024 16:32:47 -0700 Subject: [PATCH 4/6] revert --- arrow-cast/Cargo.toml | 4 --- arrow-cast/benches/cast_decimal.rs | 46 ------------------------------ 2 files changed, 50 deletions(-) delete mode 100644 arrow-cast/benches/cast_decimal.rs diff --git a/arrow-cast/Cargo.toml b/arrow-cast/Cargo.toml index a62e25eb9a57..4046f5226094 100644 --- a/arrow-cast/Cargo.toml +++ b/arrow-cast/Cargo.toml @@ -77,7 +77,3 @@ harness = false [[bench]] name = "parse_decimal" harness = false - -[[bench]] -name = "cast_decimal" -harness = false diff --git a/arrow-cast/benches/cast_decimal.rs b/arrow-cast/benches/cast_decimal.rs deleted file mode 100644 index cc85fc171137..000000000000 --- a/arrow-cast/benches/cast_decimal.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -use arrow_array::{ArrayRef, Decimal128Array}; -use arrow_cast::{cast_with_options, CastOptions}; -use arrow_schema::DataType; -use criterion::*; -use std::sync::Arc; - -fn criterion_benchmark(c: &mut Criterion) { - let decimals: ArrayRef = Arc::new( - Decimal128Array::from(vec![ - 0, - 1234, - -1234, - 1234567, - -1234567, - i128::MAX, - i128::MIN, - ]) - .with_precision_and_scale(24, 2) - .unwrap(), - ); - let options = CastOptions::default(); - let d = black_box(decimals); - c.bench_function("cast_decimal", |b| { - b.iter(|| cast_with_options(&d, &DataType::Decimal128(6, 2), &options).unwrap()); - }); -} - -criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); From bd38276c1cedbd9d33a499607cf9e3661fb52753 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Fri, 6 Dec 2024 16:48:55 -0700 Subject: [PATCH 5/6] criterion disable default features --- arrow-schema/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arrow-schema/Cargo.toml b/arrow-schema/Cargo.toml index 4b5e7a22e263..eeae6574092f 100644 --- a/arrow-schema/Cargo.toml +++ b/arrow-schema/Cargo.toml @@ -36,7 +36,7 @@ bench = false [dependencies] serde = { version = "1.0", default-features = false, features = ["derive", "std", "rc"], optional = true } bitflags = { version = "2.0.0", default-features = false, optional = true } -criterion = "0.5.1" +criterion = { version = "0.5", default-features = false } [features] # Enable ffi support From 712dfebfc1373e0e5df1693b95a8ac5facaf3214 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Sat, 7 Dec 2024 08:35:39 -0700 Subject: [PATCH 6/6] address feedback --- arrow-schema/Cargo.toml | 2 +- arrow-schema/src/ffi.rs | 82 ++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/arrow-schema/Cargo.toml b/arrow-schema/Cargo.toml index eeae6574092f..1e1f9fbde0e4 100644 --- a/arrow-schema/Cargo.toml +++ b/arrow-schema/Cargo.toml @@ -36,7 +36,6 @@ bench = false [dependencies] serde = { version = "1.0", default-features = false, features = ["derive", "std", "rc"], optional = true } bitflags = { version = "2.0.0", default-features = false, optional = true } -criterion = { version = "0.5", default-features = false } [features] # Enable ffi support @@ -48,6 +47,7 @@ features = ["ffi"] [dev-dependencies] serde_json = "1.0" bincode = { version = "1.3.3", default-features = false } +criterion = { version = "0.5", default-features = false } [[bench]] name = "ffi" diff --git a/arrow-schema/src/ffi.rs b/arrow-schema/src/ffi.rs index c0fc8b25d85c..08b1e6d0b186 100644 --- a/arrow-schema/src/ffi.rs +++ b/arrow-schema/src/ffi.rs @@ -688,57 +688,57 @@ impl TryFrom<&DataType> for FFI_ArrowSchema { fn get_format_string(dtype: &DataType) -> Result, ArrowError> { match dtype { - DataType::Null => Ok(Cow::Borrowed("n")), - DataType::Boolean => Ok(Cow::Borrowed("b")), - DataType::Int8 => Ok(Cow::Borrowed("c")), - DataType::UInt8 => Ok(Cow::Borrowed("C")), - DataType::Int16 => Ok(Cow::Borrowed("s")), - DataType::UInt16 => Ok(Cow::Borrowed("S")), - DataType::Int32 => Ok(Cow::Borrowed("i")), - DataType::UInt32 => Ok(Cow::Borrowed("I")), - DataType::Int64 => Ok(Cow::Borrowed("l")), - DataType::UInt64 => Ok(Cow::Borrowed("L")), - DataType::Float16 => Ok(Cow::Borrowed("e")), - DataType::Float32 => Ok(Cow::Borrowed("f")), - DataType::Float64 => Ok(Cow::Borrowed("g")), - DataType::BinaryView => Ok(Cow::Borrowed("vz")), - DataType::Binary => Ok(Cow::Borrowed("z")), - DataType::LargeBinary => Ok(Cow::Borrowed("Z")), - DataType::Utf8View => Ok(Cow::Borrowed("vu")), - DataType::Utf8 => Ok(Cow::Borrowed("u")), - DataType::LargeUtf8 => Ok(Cow::Borrowed("U")), + DataType::Null => Ok("n".into()), + DataType::Boolean => Ok("b".into()), + DataType::Int8 => Ok("c".into()), + DataType::UInt8 => Ok("C".into()), + DataType::Int16 => Ok("s".into()), + DataType::UInt16 => Ok("S".into()), + DataType::Int32 => Ok("i".into()), + DataType::UInt32 => Ok("I".into()), + DataType::Int64 => Ok("l".into()), + DataType::UInt64 => Ok("L".into()), + DataType::Float16 => Ok("e".into()), + DataType::Float32 => Ok("f".into()), + DataType::Float64 => Ok("g".into()), + DataType::BinaryView => Ok("vz".into()), + DataType::Binary => Ok("z".into()), + DataType::LargeBinary => Ok("Z".into()), + DataType::Utf8View => Ok("vu".into()), + DataType::Utf8 => Ok("u".into()), + DataType::LargeUtf8 => Ok("U".into()), DataType::FixedSizeBinary(num_bytes) => Ok(Cow::Owned(format!("w:{num_bytes}"))), DataType::FixedSizeList(_, num_elems) => Ok(Cow::Owned(format!("+w:{num_elems}"))), DataType::Decimal128(precision, scale) => Ok(Cow::Owned(format!("d:{precision},{scale}"))), DataType::Decimal256(precision, scale) => { Ok(Cow::Owned(format!("d:{precision},{scale},256"))) } - DataType::Date32 => Ok(Cow::Borrowed("tdD")), - DataType::Date64 => Ok(Cow::Borrowed("tdm")), - DataType::Time32(TimeUnit::Second) => Ok(Cow::Borrowed("tts")), - DataType::Time32(TimeUnit::Millisecond) => Ok(Cow::Borrowed("ttm")), - DataType::Time64(TimeUnit::Microsecond) => Ok(Cow::Borrowed("ttu")), - DataType::Time64(TimeUnit::Nanosecond) => Ok(Cow::Borrowed("ttn")), - DataType::Timestamp(TimeUnit::Second, None) => Ok(Cow::Borrowed("tss:")), - DataType::Timestamp(TimeUnit::Millisecond, None) => Ok(Cow::Borrowed("tsm:")), - DataType::Timestamp(TimeUnit::Microsecond, None) => Ok(Cow::Borrowed("tsu:")), - DataType::Timestamp(TimeUnit::Nanosecond, None) => Ok(Cow::Borrowed("tsn:")), + DataType::Date32 => Ok("tdD".into()), + DataType::Date64 => Ok("tdm".into()), + DataType::Time32(TimeUnit::Second) => Ok("tts".into()), + DataType::Time32(TimeUnit::Millisecond) => Ok("ttm".into()), + DataType::Time64(TimeUnit::Microsecond) => Ok("ttu".into()), + DataType::Time64(TimeUnit::Nanosecond) => Ok("ttn".into()), + DataType::Timestamp(TimeUnit::Second, None) => Ok("tss:".into()), + DataType::Timestamp(TimeUnit::Millisecond, None) => Ok("tsm:".into()), + DataType::Timestamp(TimeUnit::Microsecond, None) => Ok("tsu:".into()), + DataType::Timestamp(TimeUnit::Nanosecond, None) => Ok("tsn:".into()), DataType::Timestamp(TimeUnit::Second, Some(tz)) => Ok(Cow::Owned(format!("tss:{tz}"))), DataType::Timestamp(TimeUnit::Millisecond, Some(tz)) => Ok(Cow::Owned(format!("tsm:{tz}"))), DataType::Timestamp(TimeUnit::Microsecond, Some(tz)) => Ok(Cow::Owned(format!("tsu:{tz}"))), DataType::Timestamp(TimeUnit::Nanosecond, Some(tz)) => Ok(Cow::Owned(format!("tsn:{tz}"))), - DataType::Duration(TimeUnit::Second) => Ok(Cow::Borrowed("tDs")), - DataType::Duration(TimeUnit::Millisecond) => Ok(Cow::Borrowed("tDm")), - DataType::Duration(TimeUnit::Microsecond) => Ok(Cow::Borrowed("tDu")), - DataType::Duration(TimeUnit::Nanosecond) => Ok(Cow::Borrowed("tDn")), - DataType::Interval(IntervalUnit::YearMonth) => Ok(Cow::Borrowed("tiM")), - DataType::Interval(IntervalUnit::DayTime) => Ok(Cow::Borrowed("tiD")), - DataType::Interval(IntervalUnit::MonthDayNano) => Ok(Cow::Borrowed("tin")), - DataType::List(_) => Ok(Cow::Borrowed("+l")), - DataType::LargeList(_) => Ok(Cow::Borrowed("+L")), - DataType::Struct(_) => Ok(Cow::Borrowed("+s")), - DataType::Map(_, _) => Ok(Cow::Borrowed("+m")), - DataType::RunEndEncoded(_, _) => Ok(Cow::Borrowed("+r")), + DataType::Duration(TimeUnit::Second) => Ok("tDs".into()), + DataType::Duration(TimeUnit::Millisecond) => Ok("tDm".into()), + DataType::Duration(TimeUnit::Microsecond) => Ok("tDu".into()), + DataType::Duration(TimeUnit::Nanosecond) => Ok("tDn".into()), + DataType::Interval(IntervalUnit::YearMonth) => Ok("tiM".into()), + DataType::Interval(IntervalUnit::DayTime) => Ok("tiD".into()), + DataType::Interval(IntervalUnit::MonthDayNano) => Ok("tin".into()), + DataType::List(_) => Ok("+l".into()), + DataType::LargeList(_) => Ok("+L".into()), + DataType::Struct(_) => Ok("+s".into()), + DataType::Map(_, _) => Ok("+m".into()), + DataType::RunEndEncoded(_, _) => Ok("+r".into()), DataType::Dictionary(key_data_type, _) => get_format_string(key_data_type), DataType::Union(fields, mode) => { let formats = fields