Jefffrey commented on PR #23676:
URL: https://github.com/apache/datafusion/pull/23676#issuecomment-5307961099
would something like this also work without needing to modify logic other
than the signature?
```rust
pub fn new() -> Self {
// Converts decimals & integers to float64, accepting other floats as is
let as_float = Coercion::new_implicit(
TypeSignatureClass::Float,
vec![TypeSignatureClass::Numeric],
NativeType::Float64,
);
let float16 =
Coercion::new_exact(TypeSignatureClass::Native(logical_float16()));
let float32 = Coercion::new_implicit_native(
logical_float32(),
vec![TypeSignatureClass::Native(logical_float16())],
);
let float64 = Coercion::new_implicit_native(
logical_float64(),
vec![TypeSignatureClass::Numeric],
);
Self {
signature: Signature::one_of(
// Ensure decimals have precedence over floats since we have
// a native decimal implementation for log
vec![
// log(value)
TypeSignature::Coercible(vec![Coercion::new_exact(
TypeSignatureClass::Decimal,
)]),
TypeSignature::Coercible(vec![as_float.clone()]),
// log(base, value)
TypeSignature::Coercible(vec![
as_float.clone(),
Coercion::new_exact(TypeSignatureClass::Decimal),
]),
// Widen floats to the widest type
TypeSignature::Coercible(vec![float16.clone(),
float16.clone()]), // accepts only f16,f16
TypeSignature::Coercible(vec![float32.clone(),
float32.clone()]), // accepts mix of f32 & f16, promoting both to f32
TypeSignature::Coercible(vec![float64.clone(),
float64.clone()]), // both promoted to f64 for all other inputs
],
Volatility::Immutable,
),
}
}
```
--
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]