theirix commented on code in PR #18032:
URL: https://github.com/apache/datafusion/pull/18032#discussion_r2507357166
##########
datafusion/functions/src/math/power.rs:
##########
@@ -91,58 +194,209 @@ impl ScalarUDFImpl for PowerFunc {
}
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
- match arg_types[0] {
- DataType::Int64 => Ok(DataType::Int64),
- _ => Ok(DataType::Float64),
+ // Ok(arg_types[0].clone())
+ let [data_type, _] = take_function_args(self.name(), arg_types)?;
+ match data_type {
+ d if d.is_floating() => Ok(DataType::Float64),
+ d if d.is_integer() => Ok(DataType::Int64),
+ d if is_decimal(data_type) => Ok(d.clone()),
+ // DataType::Decimal32(p, s) => Ok(DataType::Decimal32(*p, *s)),
+ // DataType::Decimal64(p, s) => Ok(DataType::Decimal64(*p, 0)),
+ // DataType::Decimal128(p, s) => Ok(DataType::Decimal128(*p, 0)),
+ // DataType::Decimal256(p, s) => Ok(DataType::Decimal256(*p, 0)),
+ other => exec_err!(
+ "Unsupported data type {other:?} for {} function",
+ self.name()
+ ),
}
}
fn aliases(&self) -> &[String] {
&self.aliases
}
+ fn coerce_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
Review Comment:
Thank you for the improvement! I'll try to reformulate possible combinations
in a follow-up PR.
Also, I've added a null handling after merging your changes from #18525 ,
could you please recheck?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]