From c2b6035b63c176dfd3499baea9cbf8ec0271afee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20=C5=9Eahin?= <124376117+berkaysynnada@users.noreply.github.com> Date: Thu, 19 Dec 2024 02:45:24 +0300 Subject: [PATCH] Minor: Extend ScalarValue::new_zero() (#13828) * Update mod.rs * Update mod.rs * Update mod.rs * Update mod.rs --- datafusion/common/src/scalar/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/datafusion/common/src/scalar/mod.rs b/datafusion/common/src/scalar/mod.rs index 2daf2f37874b..feb3c6f604f0 100644 --- a/datafusion/common/src/scalar/mod.rs +++ b/datafusion/common/src/scalar/mod.rs @@ -1150,6 +1150,12 @@ impl ScalarValue { DataType::Float16 => ScalarValue::Float16(Some(f16::from_f32(0.0))), DataType::Float32 => ScalarValue::Float32(Some(0.0)), DataType::Float64 => ScalarValue::Float64(Some(0.0)), + DataType::Decimal128(precision, scale) => { + ScalarValue::Decimal128(Some(0), *precision, *scale) + } + DataType::Decimal256(precision, scale) => { + ScalarValue::Decimal256(Some(i256::ZERO), *precision, *scale) + } DataType::Timestamp(TimeUnit::Second, tz) => { ScalarValue::TimestampSecond(Some(0), tz.clone()) } @@ -1162,6 +1168,16 @@ impl ScalarValue { DataType::Timestamp(TimeUnit::Nanosecond, tz) => { ScalarValue::TimestampNanosecond(Some(0), tz.clone()) } + DataType::Time32(TimeUnit::Second) => ScalarValue::Time32Second(Some(0)), + DataType::Time32(TimeUnit::Millisecond) => { + ScalarValue::Time32Millisecond(Some(0)) + } + DataType::Time64(TimeUnit::Microsecond) => { + ScalarValue::Time64Microsecond(Some(0)) + } + DataType::Time64(TimeUnit::Nanosecond) => { + ScalarValue::Time64Nanosecond(Some(0)) + } DataType::Interval(IntervalUnit::YearMonth) => { ScalarValue::IntervalYearMonth(Some(0)) } @@ -1181,6 +1197,8 @@ impl ScalarValue { DataType::Duration(TimeUnit::Nanosecond) => { ScalarValue::DurationNanosecond(Some(0)) } + DataType::Date32 => ScalarValue::Date32(Some(0)), + DataType::Date64 => ScalarValue::Date64(Some(0)), _ => { return _not_impl_err!( "Can't create a zero scalar from data_type \"{datatype:?}\""