@@ -1895,13 +1895,28 @@ mod tests {
18951895 struct File {
18961896 name : & ' static str ,
18971897 date : & ' static str ,
1898- statistics : Vec < Option < ( f64 , f64 ) > > ,
1898+ statistics : Vec < Option < ( Option < f64 > , Option < f64 > ) > > ,
18991899 }
19001900 impl File {
19011901 fn new (
19021902 name : & ' static str ,
19031903 date : & ' static str ,
19041904 statistics : Vec < Option < ( f64 , f64 ) > > ,
1905+ ) -> Self {
1906+ Self :: new_nullable (
1907+ name,
1908+ date,
1909+ statistics
1910+ . into_iter ( )
1911+ . map ( |opt| opt. map ( |( min, max) | ( Some ( min) , Some ( max) ) ) )
1912+ . collect ( ) ,
1913+ )
1914+ }
1915+
1916+ fn new_nullable (
1917+ name : & ' static str ,
1918+ date : & ' static str ,
1919+ statistics : Vec < Option < ( Option < f64 > , Option < f64 > ) > > ,
19051920 ) -> Self {
19061921 Self {
19071922 name,
@@ -1968,21 +1983,35 @@ mod tests {
19681983 sort: vec![ col( "value" ) . sort( false , true ) ] ,
19691984 expected_result: Ok ( vec![ vec![ "1" , "0" ] , vec![ "2" ] ] ) ,
19701985 } ,
1971- // reject nullable sort columns
19721986 TestCase {
1973- name: "no nullable sort columns" ,
1987+ name: "nullable sort columns, nulls last " ,
19741988 file_schema: Schema :: new( vec![ Field :: new(
19751989 "value" . to_string( ) ,
19761990 DataType :: Float64 ,
1977- true , // should fail because nullable
1991+ true ,
19781992 ) ] ) ,
19791993 files: vec![
1980- File :: new ( "0" , "2023-01-01" , vec![ Some ( ( 0.00 , 0.49 ) ) ] ) ,
1981- File :: new ( "1" , "2023-01-01" , vec![ Some ( ( 0.50 , 1.00 ) ) ] ) ,
1982- File :: new ( "2" , "2023-01-02" , vec![ Some ( ( 0.00 , 1.00 ) ) ] ) ,
1994+ File :: new_nullable ( "0" , "2023-01-01" , vec![ Some ( ( Some ( 0.00 ) , Some ( 0.49 ) ) ) ] ) ,
1995+ File :: new_nullable ( "1" , "2023-01-01" , vec![ Some ( ( Some ( 0.50 ) , None ) ) ] ) ,
1996+ File :: new_nullable ( "2" , "2023-01-02" , vec![ Some ( ( Some ( 0.00 ) , None ) ) ] ) ,
19831997 ] ,
19841998 sort: vec![ col( "value" ) . sort( true , false ) ] ,
1985- expected_result: Err ( "construct min/max statistics for split_groups_by_statistics\n caused by\n build min rows\n caused by\n create sorting columns\n caused by\n Error during planning: cannot sort by nullable column" )
1999+ expected_result: Ok ( vec![ vec![ "0" , "1" ] , vec![ "2" ] ] )
2000+ } ,
2001+ TestCase {
2002+ name: "nullable sort columns, nulls first" ,
2003+ file_schema: Schema :: new( vec![ Field :: new(
2004+ "value" . to_string( ) ,
2005+ DataType :: Float64 ,
2006+ true ,
2007+ ) ] ) ,
2008+ files: vec![
2009+ File :: new_nullable( "0" , "2023-01-01" , vec![ Some ( ( None , Some ( 0.49 ) ) ) ] ) ,
2010+ File :: new_nullable( "1" , "2023-01-01" , vec![ Some ( ( Some ( 0.50 ) , Some ( 1.00 ) ) ) ] ) ,
2011+ File :: new_nullable( "2" , "2023-01-02" , vec![ Some ( ( None , Some ( 1.00 ) ) ) ] ) ,
2012+ ] ,
2013+ sort: vec![ col( "value" ) . sort( true , true ) ] ,
2014+ expected_result: Ok ( vec![ vec![ "0" , "1" ] , vec![ "2" ] ] )
19862015 } ,
19872016 TestCase {
19882017 name: "all three non-overlapping" ,
@@ -2142,12 +2171,12 @@ mod tests {
21422171 . map ( |stats| {
21432172 stats
21442173 . map ( |( min, max) | ColumnStatistics {
2145- min_value : Precision :: Exact ( ScalarValue :: from (
2146- min,
2147- ) ) ,
2148- max_value : Precision :: Exact ( ScalarValue :: from (
2149- max,
2150- ) ) ,
2174+ min_value : Precision :: Exact (
2175+ ScalarValue :: Float64 ( min) ,
2176+ ) ,
2177+ max_value : Precision :: Exact (
2178+ ScalarValue :: Float64 ( max) ,
2179+ ) ,
21512180 ..Default :: default ( )
21522181 } )
21532182 . unwrap_or_default ( )
0 commit comments