Jefffrey commented on code in PR #19027:
URL: https://github.com/apache/datafusion/pull/19027#discussion_r2579149870
##########
datafusion/spark/src/function/datetime/make_interval.rs:
##########
@@ -43,8 +43,39 @@ impl Default for SparkMakeInterval {
impl SparkMakeInterval {
pub fn new() -> Self {
+ fn int32_coercion() -> Coercion {
+ Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_int32()),
+ vec![TypeSignatureClass::Integer],
+ NativeType::Int32,
+ )
+ }
Review Comment:
```suggestion
let int32 = Coercion::new_implicit(
TypeSignatureClass::Native(logical_int32()),
vec![TypeSignatureClass::Integer],
NativeType::Int32,
)
```
Probably can just have them as variables and clone where necessary
##########
datafusion/spark/src/function/datetime/make_interval.rs:
##########
@@ -43,8 +43,39 @@ impl Default for SparkMakeInterval {
impl SparkMakeInterval {
pub fn new() -> Self {
+ fn int32_coercion() -> Coercion {
+ Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_int32()),
+ vec![TypeSignatureClass::Integer],
+ NativeType::Int32,
+ )
+ }
+
+ fn float64_coercion() -> Coercion {
+ Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_float64()),
+ vec![TypeSignatureClass::Numeric],
+ NativeType::Float64,
+ )
+ }
+
+ let mut variants = Vec::with_capacity(8);
+ variants.push(TypeSignature::Nullary);
+
+ for len in 1..=7 {
Review Comment:
I think I would prefer inlining the signature instead of generating it via
this for loop logic; for example:
```rust
Signature::one_of(
vec![
TypeSignature::Nullary,
// year
TypeSignature::Coercible(vec![float64.clone()]),
// year, month
TypeSignature::Coercible(vec![float64.clone(), float64.clone()]),
// etc.
],
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]