Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions datafusion/functions/src/datetime/to_timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use arrow::array::{
use arrow::datatypes::DataType::*;
use arrow::datatypes::TimeUnit::{Microsecond, Millisecond, Nanosecond, Second};
use arrow::datatypes::{
ArrowTimestampType, DataType, TimestampMicrosecondType, TimestampMillisecondType,
TimestampNanosecondType, TimestampSecondType,
ArrowTimestampType, DECIMAL128_MAX_PRECISION, DataType, TimestampMicrosecondType,
TimestampMillisecondType, TimestampNanosecondType, TimestampSecondType,
};
use datafusion_common::config::ConfigOptions;
use datafusion_common::{Result, ScalarType, ScalarValue, exec_err};
Expand Down Expand Up @@ -474,7 +474,8 @@ impl ScalarUDFImpl for ToTimestampFunc {
_ => exec_err!("Invalid Float64 value for to_timestamp"),
},
Decimal32(_, _) | Decimal64(_, _) | Decimal256(_, _) => {
let arg = args[0].cast_to(&Decimal128(38, 9), None)?;
let arg =
args[0].cast_to(&Decimal128(DECIMAL128_MAX_PRECISION, 9), None)?;
decimal128_to_timestamp_nanos(&arg, tz)
}
Decimal128(_, _) => decimal128_to_timestamp_nanos(&args[0], tz),
Expand Down
7 changes: 6 additions & 1 deletion datafusion/functions/src/math/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,12 @@ mod tests {
#[test]
fn test_log_decimal256_large() {
// Large Decimal256 values that don't fit in i128 now use f64 fallback
let arg_field = Field::new("a", DataType::Decimal256(38, 0), false).into();
let arg_field = Field::new(
"a",
DataType::Decimal256(DECIMAL256_MAX_PRECISION, 0),
false,
)
.into();
let args = ScalarFunctionArgs {
args: vec![
ColumnarValue::Array(Arc::new(Decimal256Array::from(vec![
Expand Down
2 changes: 1 addition & 1 deletion datafusion/spark/src/function/aggregate/try_sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn update_decimal128<T: ArrowNumericType>(
acc: &mut TrySumAccumulator<T>,
array: &PrimitiveArray<T>,
) -> Result<()> {
let precision = acc.dec_precision.unwrap_or(38);
let precision = acc.dec_precision.unwrap_or(DECIMAL128_MAX_PRECISION);

for v in array.iter().flatten() {
let v_i128 = unsafe { std::mem::transmute_copy::<T::Native, i128>(&v) };
Expand Down
Loading