@@ -27,9 +27,10 @@ use arrow::datatypes::DataType::{
2727 Binary , BinaryView , FixedSizeBinary , Int64 , LargeBinary ,
2828} ;
2929use datafusion_common:: utils:: take_function_args;
30- use datafusion_common:: { internal_datafusion_err, internal_err, plan_err , Result } ;
30+ use datafusion_common:: { internal_datafusion_err, internal_err, Result } ;
3131use datafusion_expr:: {
32- ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , Volatility ,
32+ Coercion , ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature ,
33+ TypeSignatureClass , Volatility ,
3334} ;
3435use datafusion_functions:: utils:: make_scalar_function;
3536use datafusion_functions:: { downcast_arg, downcast_named_arg} ;
@@ -48,8 +49,10 @@ impl Default for BitmapCount {
4849impl BitmapCount {
4950 pub fn new ( ) -> Self {
5051 Self {
51- // TODO: add definitive TypeSignature after https://github.com/apache/datafusion/issues/17291 is done
52- signature : Signature :: any ( 1 , Volatility :: Immutable ) ,
52+ signature : Signature :: coercible (
53+ vec ! [ Coercion :: new_exact( TypeSignatureClass :: Binary ) ] ,
54+ Volatility :: Immutable ,
55+ ) ,
5356 }
5457 }
5558}
@@ -67,15 +70,8 @@ impl ScalarUDFImpl for BitmapCount {
6770 & self . signature
6871 }
6972
70- fn return_type ( & self , arg_types : & [ DataType ] ) -> Result < DataType > {
71- match arg_types. first ( ) {
72- Some ( Binary | BinaryView | FixedSizeBinary ( _) | LargeBinary ) => Ok ( Int64 ) ,
73- Some ( data_type) => plan_err ! (
74- "bitmap_count expects Binary/BinaryView/FixedSizeBinary/LargeBinary as argument, got {:?}" ,
75- data_type
76- ) ,
77- None => internal_err ! ( "bitmap_count does not support zero arguments" ) ,
78- }
73+ fn return_type ( & self , _arg_types : & [ DataType ] ) -> Result < DataType > {
74+ Ok ( Int64 )
7975 }
8076
8177 fn invoke_with_args ( & self , args : ScalarFunctionArgs ) -> Result < ColumnarValue > {
0 commit comments