This is an automated email from the ASF dual-hosted git repository.
scovich pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 9ec9f578fc Deprecate ArrowTimestampType::make_value in favor of
from_naive_datetime (#9491)
9ec9f578fc is described below
commit 9ec9f578fc7e1fa38534e3cf4859822c50001be5
Author: Yan Tingwang <[email protected]>
AuthorDate: Tue Mar 3 04:24:31 2026 +0800
Deprecate ArrowTimestampType::make_value in favor of from_naive_datetime
(#9491)
Mark ArrowTimestampType::make_value as deprecated and migrate internal
callers to the newer from_naive_datetime API.
# Which issue does this PR close?
- Closes #9490 .
# Rationale for this change
Follow-up from PR #9345.
# What changes are included in this PR?
Mark ArrowTimestampType::make_value as deprecated and migrate internal
callers to the newer from_naive_datetime API.
# Are these changes tested?
YES.
# Are there any user-facing changes?
Migration Path: Users should replace:
```rust
// Old
TimestampSecondType::make_value(naive)
```
With:
```rust
// New
TimestampSecondType::from_naive_datetime(naive, None)
```
---
arrow-arith/src/numeric.rs | 5 ++++-
arrow-array/src/types.rs | 21 ++++++++-------------
arrow-cast/src/cast/mod.rs | 2 +-
arrow-cast/src/cast/string.rs | 4 ++--
arrow/tests/arithmetic.rs | 2 +-
parquet-variant-compute/src/type_conversion.rs | 16 ++++++++--------
6 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/arrow-arith/src/numeric.rs b/arrow-arith/src/numeric.rs
index a57ba67544..f5a844ffd2 100644
--- a/arrow-arith/src/numeric.rs
+++ b/arrow-arith/src/numeric.rs
@@ -1320,7 +1320,10 @@ mod tests {
"1960-01-30T04:23:20Z",
]
.into_iter()
- .map(|x|
T::make_value(DateTime::parse_from_rfc3339(x).unwrap().naive_utc()).unwrap())
+ .map(|x| {
+
T::from_naive_datetime(DateTime::parse_from_rfc3339(x).unwrap().naive_utc(),
None)
+ .unwrap()
+ })
.collect();
let a = PrimitiveArray::<T>::new(values, None);
diff --git a/arrow-array/src/types.rs b/arrow-array/src/types.rs
index ff1caaacae..267011d8af 100644
--- a/arrow-array/src/types.rs
+++ b/arrow-array/src/types.rs
@@ -324,6 +324,7 @@ pub trait ArrowTimestampType: ArrowTemporalType<Native =
i64> {
/// Creates a ArrowTimestampType::Native from the provided
[`NaiveDateTime`]
///
/// See [`DataType::Timestamp`] for more information on timezone handling
+ #[deprecated(since = "58.1.0", note = "Use from_naive_datetime instead")]
fn make_value(naive: NaiveDateTime) -> Option<i64>;
/// Creates a timestamp value from a [`DateTime`] in any timezone.
@@ -350,7 +351,7 @@ pub trait ArrowTimestampType: ArrowTemporalType<Native =
i64> {
chrono::offset::LocalResult::Ambiguous(dt1, _) =>
Self::from_datetime(dt1),
chrono::offset::LocalResult::None => None,
},
- None => Self::make_value(naive),
+ None => Self::from_datetime(naive.and_utc()),
}
}
}
@@ -416,8 +417,7 @@ fn add_year_months<T: ArrowTimestampType>(
let months = IntervalYearMonthType::to_months(delta);
let res = as_datetime_with_timezone::<T>(timestamp, tz)?;
let res = add_months_datetime(res, months)?;
- let res = res.naive_utc();
- T::make_value(res)
+ T::from_naive_datetime(res.naive_utc(), None)
}
fn add_day_time<T: ArrowTimestampType>(
@@ -429,8 +429,7 @@ fn add_day_time<T: ArrowTimestampType>(
let res = as_datetime_with_timezone::<T>(timestamp, tz)?;
let res = add_days_datetime(res, days)?;
let res = res.checked_add_signed(Duration::try_milliseconds(ms as i64)?)?;
- let res = res.naive_utc();
- T::make_value(res)
+ T::from_naive_datetime(res.naive_utc(), None)
}
fn add_month_day_nano<T: ArrowTimestampType>(
@@ -443,8 +442,7 @@ fn add_month_day_nano<T: ArrowTimestampType>(
let res = add_months_datetime(res, months)?;
let res = add_days_datetime(res, days)?;
let res = res.checked_add_signed(Duration::nanoseconds(nanos))?;
- let res = res.naive_utc();
- T::make_value(res)
+ T::from_naive_datetime(res.naive_utc(), None)
}
fn subtract_year_months<T: ArrowTimestampType>(
@@ -455,8 +453,7 @@ fn subtract_year_months<T: ArrowTimestampType>(
let months = IntervalYearMonthType::to_months(delta);
let res = as_datetime_with_timezone::<T>(timestamp, tz)?;
let res = sub_months_datetime(res, months)?;
- let res = res.naive_utc();
- T::make_value(res)
+ T::from_naive_datetime(res.naive_utc(), None)
}
fn subtract_day_time<T: ArrowTimestampType>(
@@ -468,8 +465,7 @@ fn subtract_day_time<T: ArrowTimestampType>(
let res = as_datetime_with_timezone::<T>(timestamp, tz)?;
let res = sub_days_datetime(res, days)?;
let res = res.checked_sub_signed(Duration::try_milliseconds(ms as i64)?)?;
- let res = res.naive_utc();
- T::make_value(res)
+ T::from_naive_datetime(res.naive_utc(), None)
}
fn subtract_month_day_nano<T: ArrowTimestampType>(
@@ -482,8 +478,7 @@ fn subtract_month_day_nano<T: ArrowTimestampType>(
let res = sub_months_datetime(res, months)?;
let res = sub_days_datetime(res, days)?;
let res = res.checked_sub_signed(Duration::nanoseconds(nanos))?;
- let res = res.naive_utc();
- T::make_value(res)
+ T::from_naive_datetime(res.naive_utc(), None)
}
impl TimestampSecondType {
diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs
index 67efb57424..9f1eba1057 100644
--- a/arrow-cast/src/cast/mod.rs
+++ b/arrow-cast/src/cast/mod.rs
@@ -2507,7 +2507,7 @@ fn adjust_timestamp_to_timezone<T: ArrowTimestampType>(
let adjust = |o| {
let local = as_datetime::<T>(o)?;
let offset = to_tz.offset_from_local_datetime(&local).single()?;
- T::make_value(local - offset.fix())
+ T::from_naive_datetime(local - offset.fix(), None)
};
let adjusted = if cast_options.safe {
array.unary_opt::<_, Int64Type>(adjust)
diff --git a/arrow-cast/src/cast/string.rs b/arrow-cast/src/cast/string.rs
index 77696ae0d8..68fce85cb4 100644
--- a/arrow-cast/src/cast/string.rs
+++ b/arrow-cast/src/cast/string.rs
@@ -168,7 +168,7 @@ fn cast_string_to_timestamp_impl<
let iter = iter.map(|v| {
v.and_then(|v| {
let naive = string_to_datetime(tz, v).ok()?.naive_utc();
- T::make_value(naive)
+ T::from_naive_datetime(naive, None)
})
});
// Benefit:
@@ -182,7 +182,7 @@ fn cast_string_to_timestamp_impl<
.map(|v| {
v.map(|v| {
let naive = string_to_datetime(tz, v)?.naive_utc();
- T::make_value(naive).ok_or_else(|| match T::UNIT {
+ T::from_naive_datetime(naive, None).ok_or_else(|| match
T::UNIT {
TimeUnit::Nanosecond => ArrowError::CastError(format!(
"Overflow converting {naive} to Nanosecond. The
dates that can be represented as nanoseconds have to be between
1677-09-21T00:12:44.0 and 2262-04-11T23:47:16.854775804"
)),
diff --git a/arrow/tests/arithmetic.rs b/arrow/tests/arithmetic.rs
index cc6a97e123..5d024f715a 100644
--- a/arrow/tests/arithmetic.rs
+++ b/arrow/tests/arithmetic.rs
@@ -76,7 +76,7 @@ fn test_timestamp_with_timezone_impl<T:
ArrowTimestampType>(tz_str: &str) {
.naive_utc(),
]
.into_iter()
- .map(|x| T::make_value(x).unwrap())
+ .map(|x| T::from_naive_datetime(x, None).unwrap())
.collect();
let a = PrimitiveArray::<T>::new(values, None).with_timezone(tz_str);
diff --git a/parquet-variant-compute/src/type_conversion.rs
b/parquet-variant-compute/src/type_conversion.rs
index 6a0a743c90..42bac5727a 100644
--- a/parquet-variant-compute/src/type_conversion.rs
+++ b/parquet-variant-compute/src/type_conversion.rs
@@ -109,7 +109,7 @@ impl_timestamp_from_variant!(
if timestamp.nanosecond() != 0 {
None
} else {
- Self::make_value(timestamp)
+ Self::from_naive_datetime(timestamp, None)
}
}
);
@@ -122,7 +122,7 @@ impl_timestamp_from_variant!(
if timestamp.nanosecond() != 0 {
None
} else {
- Self::make_value(timestamp.naive_utc())
+ Self::from_naive_datetime(timestamp.naive_utc(), None)
}
}
);
@@ -135,7 +135,7 @@ impl_timestamp_from_variant!(
if timestamp.nanosecond() % 1_000_000 != 0 {
None
} else {
- Self::make_value(timestamp)
+ Self::from_naive_datetime(timestamp, None)
}
}
);
@@ -148,7 +148,7 @@ impl_timestamp_from_variant!(
if timestamp.nanosecond() % 1_000_000 != 0 {
None
} else {
- Self::make_value(timestamp.naive_utc())
+ Self::from_naive_datetime(timestamp.naive_utc(), None)
}
}
);
@@ -156,25 +156,25 @@ impl_timestamp_from_variant!(
datatypes::TimestampMicrosecondType,
as_timestamp_ntz_micros,
ntz = true,
- Self::make_value,
+ |timestamp| Self::from_naive_datetime(timestamp, None),
);
impl_timestamp_from_variant!(
datatypes::TimestampMicrosecondType,
as_timestamp_micros,
ntz = false,
- |timestamp| Self::make_value(timestamp.naive_utc())
+ |timestamp| Self::from_naive_datetime(timestamp.naive_utc(), None)
);
impl_timestamp_from_variant!(
datatypes::TimestampNanosecondType,
as_timestamp_ntz_nanos,
ntz = true,
- Self::make_value
+ |timestamp| Self::from_naive_datetime(timestamp, None)
);
impl_timestamp_from_variant!(
datatypes::TimestampNanosecondType,
as_timestamp_nanos,
ntz = false,
- |timestamp| Self::make_value(timestamp.naive_utc())
+ |timestamp| Self::from_naive_datetime(timestamp.naive_utc(), None)
);
/// Returns the unscaled integer representation for Arrow decimal type `O`