1717
1818use arrow:: array:: types:: * ;
1919use arrow:: array:: * ;
20- use arrow:: datatypes:: { DataType , IntervalDayTime , IntervalMonthDayNano } ;
20+ use arrow:: datatypes:: { DataType , IntervalDayTime , IntervalMonthDayNano , IntervalUnit } ;
2121use bigdecimal:: num_traits:: WrappingNeg ;
2222use datafusion_common:: utils:: take_function_args;
2323use datafusion_common:: { Result , ScalarValue , not_impl_err} ;
2424use datafusion_expr:: {
25- ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , Volatility ,
25+ ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , TypeSignature ,
26+ Volatility ,
2627} ;
2728use std:: any:: Any ;
2829use std:: sync:: Arc ;
@@ -56,7 +57,23 @@ impl Default for SparkNegative {
5657impl SparkNegative {
5758 pub fn new ( ) -> Self {
5859 Self {
59- signature : Signature :: any ( 1 , Volatility :: Immutable ) ,
60+ signature : Signature {
61+ type_signature : TypeSignature :: OneOf ( vec ! [
62+ // Numeric types: signed/unsigned integers, float, decimals
63+ TypeSignature :: Numeric ( 1 ) ,
64+ // Interval types: YearMonth, DayTime, MonthDayNano
65+ TypeSignature :: Uniform (
66+ 1 ,
67+ vec![
68+ DataType :: Interval ( IntervalUnit :: YearMonth ) ,
69+ DataType :: Interval ( IntervalUnit :: DayTime ) ,
70+ DataType :: Interval ( IntervalUnit :: MonthDayNano ) ,
71+ ] ,
72+ ) ,
73+ ] ) ,
74+ volatility : Volatility :: Immutable ,
75+ parameter_names : None ,
76+ } ,
6077 }
6178 }
6279}
@@ -161,13 +178,13 @@ fn spark_negative(args: &[ColumnarValue]) -> Result<ColumnarValue> {
161178 }
162179
163180 // interval type
164- DataType :: Interval ( arrow :: datatypes :: IntervalUnit :: YearMonth ) => {
181+ DataType :: Interval ( IntervalUnit :: YearMonth ) => {
165182 let array = array. as_primitive :: < IntervalYearMonthType > ( ) ;
166183 let result: PrimitiveArray < IntervalYearMonthType > =
167184 array. unary ( |x| x. wrapping_neg ( ) ) ;
168185 Ok ( ColumnarValue :: Array ( Arc :: new ( result) ) )
169186 }
170- DataType :: Interval ( arrow :: datatypes :: IntervalUnit :: DayTime ) => {
187+ DataType :: Interval ( IntervalUnit :: DayTime ) => {
171188 let array = array. as_primitive :: < IntervalDayTimeType > ( ) ;
172189 let result: PrimitiveArray < IntervalDayTimeType > =
173190 array. unary ( |x| IntervalDayTime {
@@ -176,7 +193,7 @@ fn spark_negative(args: &[ColumnarValue]) -> Result<ColumnarValue> {
176193 } ) ;
177194 Ok ( ColumnarValue :: Array ( Arc :: new ( result) ) )
178195 }
179- DataType :: Interval ( arrow :: datatypes :: IntervalUnit :: MonthDayNano ) => {
196+ DataType :: Interval ( IntervalUnit :: MonthDayNano ) => {
180197 let array = array. as_primitive :: < IntervalMonthDayNanoType > ( ) ;
181198 let result: PrimitiveArray < IntervalMonthDayNanoType > =
182199 array. unary ( |x| IntervalMonthDayNano {
0 commit comments