This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new e74b83ab02 fix: date overflow panic (#21233)
e74b83ab02 is described below
commit e74b83ab026379158a8031c9d70f187fbb704172
Author: Huaijin <[email protected]>
AuthorDate: Wed Apr 1 02:27:21 2026 +0800
fix: date overflow panic (#21233)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes #21234
## Rationale for this change
- see #21234
## What changes are included in this PR?
handle Date32 and Date64 in `get_extreme_value` function
## Are these changes tested?
yes, add test case
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---------
Co-authored-by: Andrew Lamb <[email protected]>
---
datafusion/expr-common/src/interval_arithmetic.rs | 2 ++
.../sqllogictest/test_files/datetime/arith_date_interval.slt | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/datafusion/expr-common/src/interval_arithmetic.rs
b/datafusion/expr-common/src/interval_arithmetic.rs
index 0f88723d11..883c721080 100644
--- a/datafusion/expr-common/src/interval_arithmetic.rs
+++ b/datafusion/expr-common/src/interval_arithmetic.rs
@@ -49,6 +49,8 @@ macro_rules! get_extreme_value {
DataType::Int64 => ScalarValue::Int64(Some(i64::$extreme)),
DataType::Float32 => ScalarValue::Float32(Some(f32::$extreme)),
DataType::Float64 => ScalarValue::Float64(Some(f64::$extreme)),
+ DataType::Date32 => ScalarValue::Date32(Some(i32::$extreme)),
+ DataType::Date64 => ScalarValue::Date64(Some(i64::$extreme)),
DataType::Duration(TimeUnit::Second) => {
ScalarValue::DurationSecond(Some(i64::$extreme))
}
diff --git
a/datafusion/sqllogictest/test_files/datetime/arith_date_interval.slt
b/datafusion/sqllogictest/test_files/datetime/arith_date_interval.slt
index ad2e7ed496..01e1939996 100644
--- a/datafusion/sqllogictest/test_files/datetime/arith_date_interval.slt
+++ b/datafusion/sqllogictest/test_files/datetime/arith_date_interval.slt
@@ -35,3 +35,15 @@ query T
SELECT arrow_typeof('2001-09-28'::date - interval '25 hour')
----
Date32
+
+query error Arrow error: Compute error: Date arithmetic overflow
+SELECT arrow_cast('2020-01-01', 'Date32') + INTERVAL '999999' YEAR
+
+query error Arrow error: Compute error: Date arithmetic overflow
+SELECT arrow_cast('2020-01-01', 'Date32') - INTERVAL '999999' YEAR
+
+query error Arrow error: Compute error: Date arithmetic overflow
+SELECT arrow_cast('2020-01-01', 'Date64') + INTERVAL '999999' YEAR
+
+query error Arrow error: Compute error: Date arithmetic overflow
+SELECT arrow_cast('2020-01-01', 'Date64') - INTERVAL '999999' YEAR
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]