Skip to content

Commit bd86ee5

Browse files
committed
fix issues with nanvl
1 parent f2b196e commit bd86ee5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

datafusion/functions/src/math/nanvl.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,17 @@ impl ScalarUDFImpl for NanvlFunc {
107107
.cast_to(args.return_type(), None);
108108
}
109109

110-
let target_type = if args
111-
.args
112-
.iter()
113-
.all(|arg| matches!(arg.data_type(), Float32))
114-
{
115-
Float32
116-
} else {
117-
Float64
118-
};
110+
let target_type = args.return_type();
111+
if !matches!(target_type, Float32 | Float64) {
112+
return exec_err!(
113+
"Unsupported return type {target_type:?} for function nanvl"
114+
);
115+
}
119116

120117
let casted_args = args
121118
.args
122119
.iter()
123-
.map(|arg| arg.cast_to(&target_type, None))
120+
.map(|arg| arg.cast_to(target_type, None))
124121
.collect::<Result<Vec<_>>>()?;
125122

126123
make_scalar_function(nanvl, vec![])(&casted_args)

0 commit comments

Comments
 (0)