@@ -39,7 +39,7 @@ use std::{convert::TryFrom, fmt, iter::repeat, sync::Arc};
3939/// This is the single-valued counter-part of arrow’s `Array`.
4040#[ derive( Clone ) ]
4141pub enum ScalarValue {
42- /// represents null
42+ /// represents `DataType::Null` (castable to/from any other type)
4343 Null ,
4444 /// true or false value
4545 Boolean ( Option < bool > ) ,
@@ -172,6 +172,7 @@ impl PartialEq for ScalarValue {
172172 ( IntervalMonthDayNano ( _) , _) => false ,
173173 ( Struct ( v1, t1) , Struct ( v2, t2) ) => v1. eq ( v2) && t1. eq ( t2) ,
174174 ( Struct ( _, _) , _) => false ,
175+ ( Null , Null ) => true ,
175176 ( Null , _) => false ,
176177 }
177178 }
@@ -273,6 +274,7 @@ impl PartialOrd for ScalarValue {
273274 }
274275 }
275276 ( Struct ( _, _) , _) => None ,
277+ ( Null , Null ) => Some ( Ordering :: Equal ) ,
276278 ( Null , _) => None ,
277279 }
278280 }
@@ -844,10 +846,7 @@ impl ScalarValue {
844846 ScalarValue :: iter_to_decimal_array ( scalars, precision, scale) ?;
845847 Arc :: new ( decimal_array)
846848 }
847- DataType :: Null => {
848- let null_array = ScalarValue :: iter_to_null_array ( scalars) ?;
849- Arc :: new ( null_array)
850- }
849+ DataType :: Null => ScalarValue :: iter_to_null_array ( scalars) ,
851850 DataType :: Boolean => build_array_primitive ! ( BooleanArray , Boolean ) ,
852851 DataType :: Float32 => build_array_primitive ! ( Float32Array , Float32 ) ,
853852 DataType :: Float64 => build_array_primitive ! ( Float64Array , Float64 ) ,
@@ -980,18 +979,15 @@ impl ScalarValue {
980979 Ok ( array)
981980 }
982981
983- fn iter_to_null_array (
984- scalars : impl IntoIterator < Item = ScalarValue > ,
985- ) -> Result < NullArray > {
982+ fn iter_to_null_array ( scalars : impl IntoIterator < Item = ScalarValue > ) -> ArrayRef {
986983 let length =
987984 scalars
988985 . into_iter ( )
989986 . fold ( 0usize , |r, element : ScalarValue | match element {
990987 ScalarValue :: Null => r + 1 ,
991988 _ => unreachable ! ( ) ,
992989 } ) ;
993- let array = NullArray :: new ( length) ;
994- Ok ( array)
990+ new_null_array ( & DataType :: Null , length)
995991 }
996992
997993 fn iter_to_decimal_array (
@@ -1550,7 +1546,7 @@ impl ScalarValue {
15501546 eq_array_primitive ! ( array, index, IntervalMonthDayNanoArray , val)
15511547 }
15521548 ScalarValue :: Struct ( _, _) => unimplemented ! ( ) ,
1553- ScalarValue :: Null => false ,
1549+ ScalarValue :: Null => array . data ( ) . is_null ( index ) ,
15541550 }
15551551 }
15561552
0 commit comments