@@ -1657,21 +1657,26 @@ fn obj_to_pairs(rows: &Array, len: usize) -> impl '_ + Iterator<Item = Vec<(Stri
1657
1657
if val. is_array ( ) . unwrap ( ) {
1658
1658
let arr: napi:: JsObject = unsafe { val. cast ( ) } ;
1659
1659
let len = arr. get_array_length ( ) . unwrap ( ) ;
1660
- // dont compare too many items, as it could be expensive
1661
- let max_take = std:: cmp:: min ( len as usize , 10 ) ;
1662
- let mut dtypes: Vec < DataType > =
1663
- Vec :: with_capacity ( len as usize ) ;
1664
-
1665
- for idx in 0 ..max_take {
1666
- let item: napi:: JsUnknown =
1667
- arr. get_element ( idx as u32 ) . unwrap ( ) ;
1668
- let ty = item. get_type ( ) . unwrap ( ) ;
1669
- let dt: Wrap < DataType > = ty. into ( ) ;
1670
- dtypes. push ( dt. 0 )
1671
- }
1672
- let dtype = coerce_data_type ( & dtypes) ;
1673
1660
1674
- DataType :: List ( dtype. into ( ) )
1661
+ if len == 0 {
1662
+ DataType :: List ( DataType :: Null . into ( ) )
1663
+ } else {
1664
+ // dont compare too many items, as it could be expensive
1665
+ let max_take = std:: cmp:: min ( len as usize , 10 ) ;
1666
+ let mut dtypes: Vec < DataType > =
1667
+ Vec :: with_capacity ( len as usize ) ;
1668
+
1669
+ for idx in 0 ..max_take {
1670
+ let item: napi:: JsUnknown =
1671
+ arr. get_element ( idx as u32 ) . unwrap ( ) ;
1672
+ let ty = item. get_type ( ) . unwrap ( ) ;
1673
+ let dt: Wrap < DataType > = ty. into ( ) ;
1674
+ dtypes. push ( dt. 0 )
1675
+ }
1676
+ let dtype = coerce_data_type ( & dtypes) ;
1677
+
1678
+ DataType :: List ( dtype. into ( ) )
1679
+ }
1675
1680
} else if val. is_date ( ) . unwrap ( ) {
1676
1681
DataType :: Datetime ( TimeUnit :: Milliseconds , None )
1677
1682
} else {
0 commit comments