|  | 
| 15 | 15 | // specific language governing permissions and limitations | 
| 16 | 16 | // under the License. | 
| 17 | 17 | 
 | 
| 18 |  | -use arrow::compute::is_not_null; | 
| 19 |  | -use arrow::compute::kernels::zip::zip; | 
| 20 | 18 | use arrow::datatypes::{DataType, Field, FieldRef}; | 
| 21 |  | -use datafusion_common::{internal_err, plan_err, utils::take_function_args, Result}; | 
|  | 19 | +use datafusion_common::{internal_err, utils::take_function_args, Result}; | 
| 22 | 20 | use datafusion_expr::{ | 
| 23 | 21 |     conditional_expressions::CaseBuilder, | 
| 24 | 22 |     simplify::{ExprSimplifyResult, SimplifyInfo}, | 
| @@ -103,35 +101,8 @@ impl ScalarUDFImpl for NVL2Func { | 
| 103 | 101 |         Ok(Field::new(self.name(), return_type, nullable).into()) | 
| 104 | 102 |     } | 
| 105 | 103 | 
 | 
| 106 |  | -    fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> { | 
| 107 |  | -        let [test, if_non_null, if_null] = take_function_args(self.name(), args.args)?; | 
| 108 |  | - | 
| 109 |  | -        match test { | 
| 110 |  | -            ColumnarValue::Scalar(test_scalar) => { | 
| 111 |  | -                if test_scalar.is_null() { | 
| 112 |  | -                    Ok(if_null) | 
| 113 |  | -                } else { | 
| 114 |  | -                    Ok(if_non_null) | 
| 115 |  | -                } | 
| 116 |  | -            } | 
| 117 |  | -            ColumnarValue::Array(test_array) => { | 
| 118 |  | -                let len = test_array.len(); | 
| 119 |  | - | 
| 120 |  | -                let if_non_null_array = match if_non_null { | 
| 121 |  | -                    ColumnarValue::Array(array) => array, | 
| 122 |  | -                    ColumnarValue::Scalar(scalar) => scalar.to_array_of_size(len)?, | 
| 123 |  | -                }; | 
| 124 |  | - | 
| 125 |  | -                let if_null_array = match if_null { | 
| 126 |  | -                    ColumnarValue::Array(array) => array, | 
| 127 |  | -                    ColumnarValue::Scalar(scalar) => scalar.to_array_of_size(len)?, | 
| 128 |  | -                }; | 
| 129 |  | - | 
| 130 |  | -                let mask = is_not_null(&test_array)?; | 
| 131 |  | -                let result = zip(&mask, &if_non_null_array, &if_null_array)?; | 
| 132 |  | -                Ok(ColumnarValue::Array(result)) | 
| 133 |  | -            } | 
| 134 |  | -        } | 
|  | 104 | +    fn invoke_with_args(&self, _args: ScalarFunctionArgs) -> Result<ColumnarValue> { | 
|  | 105 | +        internal_err!("nvl2 should have been simplified to case") | 
| 135 | 106 |     } | 
| 136 | 107 | 
 | 
| 137 | 108 |     fn simplify( | 
|  | 
0 commit comments