|
15 | 15 | // specific language governing permissions and limitations
|
16 | 16 | // under the License.
|
17 | 17 |
|
| 18 | +use arrow::array::Array; |
| 19 | +use arrow::compute::is_not_null; |
| 20 | +use arrow::compute::kernels::zip::zip; |
18 | 21 | use arrow::datatypes::DataType;
|
19 | 22 | use datafusion_common::{internal_err, Result};
|
20 | 23 | use datafusion_expr::{ColumnarValue, ScalarUDFImpl, Signature, Volatility};
|
21 |
| -use arrow::compute::kernels::zip::zip; |
22 |
| -use arrow::compute::is_not_null; |
23 |
| -use arrow::array::Array; |
24 | 24 |
|
25 | 25 | #[derive(Debug)]
|
26 | 26 | pub(super) struct NVLFunc {
|
@@ -50,8 +50,9 @@ static SUPPORTED_NVL_TYPES: &[DataType] = &[
|
50 | 50 | impl NVLFunc {
|
51 | 51 | pub fn new() -> Self {
|
52 | 52 | Self {
|
53 |
| - signature: |
54 |
| - Signature::uniform(2, SUPPORTED_NVL_TYPES.to_vec(), |
| 53 | + signature: Signature::uniform( |
| 54 | + 2, |
| 55 | + SUPPORTED_NVL_TYPES.to_vec(), |
55 | 56 | Volatility::Immutable,
|
56 | 57 | ),
|
57 | 58 | aliases: vec![String::from("ifnull")],
|
@@ -195,8 +196,11 @@ mod tests {
|
195 | 196 | let result = nvl_func(&[a, lit_array])?;
|
196 | 197 | let result = result.into_array(0).expect("Failed to convert to array");
|
197 | 198 |
|
198 |
| - let expected = |
199 |
| - Arc::new(BooleanArray::from(vec![Some(true), Some(false), Some(false)])) as ArrayRef; |
| 199 | + let expected = Arc::new(BooleanArray::from(vec![ |
| 200 | + Some(true), |
| 201 | + Some(false), |
| 202 | + Some(false), |
| 203 | + ])) as ArrayRef; |
200 | 204 |
|
201 | 205 | assert_eq!(expected.as_ref(), result.as_ref());
|
202 | 206 | Ok(())
|
@@ -251,7 +255,9 @@ mod tests {
|
251 | 255 | let b_null = ColumnarValue::Scalar(ScalarValue::Int32(Some(2i32)));
|
252 | 256 |
|
253 | 257 | let result_null = nvl_func(&[a_null, b_null])?;
|
254 |
| - let result_null = result_null.into_array(1).expect("Failed to convert to array"); |
| 258 | + let result_null = result_null |
| 259 | + .into_array(1) |
| 260 | + .expect("Failed to convert to array"); |
255 | 261 |
|
256 | 262 | let expected_null = Arc::new(Int32Array::from(vec![Some(2i32)])) as ArrayRef;
|
257 | 263 |
|
|
0 commit comments