Skip to content

Commit c65cab1

Browse files
committed
change overflow error type to DatafusionError
1 parent 4c53d73 commit c65cab1

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

datafusion/functions/src/math/factorial.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use arrow::{
19-
array::{ArrayRef, AsArray, Int64Array},
20-
error::ArrowError,
21-
};
18+
use arrow::array::{ArrayRef, AsArray, Int64Array};
2219
use std::any::Any;
2320
use std::sync::Arc;
2421

@@ -114,7 +111,7 @@ const FACTORIALS: [i64; 21] = [
114111
6402373705728000,
115112
121645100408832000,
116113
2432902008176640000,
117-
];
114+
]; // if return type changes, this constant needs to be updated accordingly
118115

119116
/// Factorial SQL function
120117
fn factorial(args: &[ArrayRef]) -> Result<ArrayRef> {
@@ -127,9 +124,7 @@ fn factorial(args: &[ArrayRef]) -> Result<ArrayRef> {
127124
} else if a < FACTORIALS.len() as i64 {
128125
Ok(FACTORIALS[a as usize])
129126
} else {
130-
Err(ArrowError::ComputeError(format!(
131-
"Overflow happened on FACTORIAL({a})"
132-
)))
127+
exec_err!("Overflow happened on FACTORIAL({a})")
133128
}
134129
})?;
135130
Ok(Arc::new(result) as ArrayRef)

datafusion/sqllogictest/test_files/math.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ select
795795
39 Decimal128(2, 1)
796796

797797
# factorial overflow
798-
query error DataFusion error: Arrow error: Compute error: Overflow happened on FACTORIAL\(350943270\)
798+
query error DataFusion error: Execution error: Overflow happened on FACTORIAL\(350943270\)
799799
select FACTORIAL(350943270);
800800

801801
statement ok

0 commit comments

Comments
 (0)