@@ -1246,10 +1246,6 @@ mod tests {
12461246 assert_eq ! ( stats, make_stats( vec![ 20 , 30 , 20 , 20 , 10 , 30 ] ) ) ;
12471247 }
12481248
1249- fn single_col_schema ( dt : DataType ) -> Schema {
1250- Schema :: new ( vec ! [ Field :: new( "a" , dt, true ) ] )
1251- }
1252-
12531249 // Make a Statistics structure with the specified null counts for each column
12541250 fn make_stats ( counts : impl IntoIterator < Item = usize > ) -> Statistics {
12551251 Statistics {
@@ -1494,7 +1490,7 @@ mod tests {
14941490 ) ;
14951491
14961492 // Merge statistics
1497- let schema = single_col_schema ( DataType :: Int32 ) ;
1493+ let schema = Schema :: new ( vec ! [ Field :: new ( "a" , DataType :: Int32 , true ) ] ) ;
14981494 let merged_stats =
14991495 Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
15001496
@@ -1538,9 +1534,8 @@ mod tests {
15381534 . with_distinct_count ( Precision :: Exact ( 8 ) ) ,
15391535 ) ;
15401536
1541- let schema = single_col_schema ( DataType :: Int32 ) ;
1542- let merged =
1543- Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
1537+ let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int32 , true ) ] ) ;
1538+ let merged = Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
15441539 // No overlap -> sum of NDVs
15451540 assert_eq ! (
15461541 merged. column_statistics[ 0 ] . distinct_count,
@@ -1567,9 +1562,8 @@ mod tests {
15671562 . with_distinct_count ( Precision :: Exact ( 30 ) ) ,
15681563 ) ;
15691564
1570- let schema = single_col_schema ( DataType :: Int32 ) ;
1571- let merged =
1572- Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
1565+ let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int32 , true ) ] ) ;
1566+ let merged = Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
15731567 // Full overlap -> max(50, 30) = 50
15741568 assert_eq ! (
15751569 merged. column_statistics[ 0 ] . distinct_count,
@@ -1596,9 +1590,8 @@ mod tests {
15961590 . with_distinct_count ( Precision :: Exact ( 60 ) ) ,
15971591 ) ;
15981592
1599- let schema = single_col_schema ( DataType :: Int32 ) ;
1600- let merged =
1601- Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
1593+ let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int32 , true ) ] ) ;
1594+ let merged = Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
16021595 // overlap=[50,100], range_left=100, range_right=100, overlap_range=50
16031596 // overlap_left=80*(50/100)=40, overlap_right=60*(50/100)=30
16041597 // result = max(40,30) + (80-40) + (60-30) = 40 + 40 + 30 = 110
@@ -1613,19 +1606,16 @@ mod tests {
16131606 let stats1 = Statistics :: default ( )
16141607 . with_num_rows ( Precision :: Exact ( 10 ) )
16151608 . add_column_statistics (
1616- ColumnStatistics :: new_unknown ( )
1617- . with_distinct_count ( Precision :: Exact ( 5 ) ) ,
1609+ ColumnStatistics :: new_unknown ( ) . with_distinct_count ( Precision :: Exact ( 5 ) ) ,
16181610 ) ;
16191611 let stats2 = Statistics :: default ( )
16201612 . with_num_rows ( Precision :: Exact ( 10 ) )
16211613 . add_column_statistics (
1622- ColumnStatistics :: new_unknown ( )
1623- . with_distinct_count ( Precision :: Exact ( 8 ) ) ,
1614+ ColumnStatistics :: new_unknown ( ) . with_distinct_count ( Precision :: Exact ( 8 ) ) ,
16241615 ) ;
16251616
1626- let schema = single_col_schema ( DataType :: Int32 ) ;
1627- let merged =
1628- Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
1617+ let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int32 , true ) ] ) ;
1618+ let merged = Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
16291619 // No min/max -> fallback to max(5, 8)
16301620 assert_eq ! (
16311621 merged. column_statistics[ 0 ] . distinct_count,
@@ -1660,9 +1650,8 @@ mod tests {
16601650 . with_distinct_count ( Precision :: Exact ( 8 ) ) ,
16611651 ) ;
16621652
1663- let schema = single_col_schema ( DataType :: Utf8 ) ;
1664- let merged =
1665- Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
1653+ let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Utf8 , true ) ] ) ;
1654+ let merged = Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
16661655 // distance() unsupported for strings -> fallback to max
16671656 assert_eq ! (
16681657 merged. column_statistics[ 0 ] . distinct_count,
@@ -1690,9 +1679,8 @@ mod tests {
16901679 . with_distinct_count ( Precision :: Exact ( 1 ) ) ,
16911680 ) ;
16921681
1693- let schema = single_col_schema ( DataType :: Int32 ) ;
1694- let merged =
1695- Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
1682+ let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int32 , true ) ] ) ;
1683+ let merged = Statistics :: try_merge_iter ( [ & stats1, & stats2] , & schema) . unwrap ( ) ;
16961684 assert_eq ! (
16971685 merged. column_statistics[ 0 ] . distinct_count,
16981686 Precision :: Inexact ( 1 )
@@ -1716,8 +1704,7 @@ mod tests {
17161704 . with_distinct_count ( Precision :: Exact ( 1 ) ) ,
17171705 ) ;
17181706
1719- let merged =
1720- Statistics :: try_merge_iter ( [ & stats3, & stats4] , & schema) . unwrap ( ) ;
1707+ let merged = Statistics :: try_merge_iter ( [ & stats3, & stats4] , & schema) . unwrap ( ) ;
17211708 assert_eq ! (
17221709 merged. column_statistics[ 0 ] . distinct_count,
17231710 Precision :: Inexact ( 2 )
0 commit comments