alamb commented on code in PR #6149:
URL: https://github.com/apache/arrow-datafusion/pull/6149#discussion_r1181617813
##########
datafusion/physical-expr/src/math_expressions.rs:
##########
@@ -167,6 +168,98 @@ math_unary_function!("log10", log10);
math_unary_function!("degrees", to_degrees);
math_unary_function!("radians", to_radians);
+/// Factorial SQL function
+pub fn factorial(args: &[ArrayRef]) -> Result<ArrayRef> {
+ match args[0].data_type() {
+ DataType::UInt64 => Ok(Arc::new(make_function_scalar_inputs!(
+ &args[0],
+ "value",
+ UInt64Array,
+ { |value: u64| { (1..=value).product() } }
+ )) as ArrayRef),
+ other => Err(DataFusionError::Internal(format!(
+ "Unsupported data type {other:?} for function factorial"
Review Comment:
```suggestion
"Unsupported data type {other:?} for function factorial.
Requires bigint"
```
I think it is nice to help the users understand what they can do to fix
their query. The same applies to the queries below
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]