Apache DataFusion SQL Query Engine
fix: date overflow panic (#21233)
Huaijine74b83ab0263
diff --git a/datafusion/expr-common/src/interval_arithmetic.rs b/datafusion/expr-common/src/interval_arithmetic.rsindex 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.sltindex 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 TSELECT 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