@@ -24,7 +24,6 @@ use context::*;
2424mod task;
2525
2626use std:: sync:: Arc ;
27- use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
2827
2928use arrow_array:: RecordBatch ;
3029use futures:: channel:: mpsc:: { Sender , channel} ;
@@ -1476,6 +1475,14 @@ pub mod tests {
14761475 let col = batches[ 0 ] . column_by_name ( "y" ) . unwrap ( ) ;
14771476 let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
14781477 assert_eq ! ( int64_arr. value( 0 ) , 2 ) ;
1478+
1479+ let col = batches[ 0 ] . column_by_name ( "x" ) . unwrap ( ) ;
1480+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1481+ assert_eq ! ( int64_arr. value( 0 ) , 1 ) ;
1482+
1483+ let col = batches[ 0 ] . column_by_name ( "y" ) . unwrap ( ) ;
1484+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1485+ assert_eq ! ( int64_arr. value( 0 ) , 2 ) ;
14791486 }
14801487
14811488 #[ tokio:: test]
@@ -1496,6 +1503,14 @@ pub mod tests {
14961503 assert_eq ! ( batches. len( ) , 2 ) ;
14971504 assert_eq ! ( batches[ 0 ] . num_rows( ) , 1 ) ;
14981505 assert_eq ! ( batches[ 1 ] . num_rows( ) , 1 ) ;
1506+
1507+ let col = batches[ 0 ] . column_by_name ( "x" ) . unwrap ( ) ;
1508+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1509+ assert_eq ! ( int64_arr. value( 0 ) , 1 ) ;
1510+
1511+ let col = batches[ 0 ] . column_by_name ( "y" ) . unwrap ( ) ;
1512+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1513+ assert_eq ! ( int64_arr. value( 0 ) , 4 ) ;
14991514 }
15001515
15011516 #[ tokio:: test]
@@ -1520,13 +1535,44 @@ pub mod tests {
15201535 assert_eq ! ( batches[ 0 ] . num_rows( ) , 1 ) ;
15211536 assert_eq ! ( batches[ 1 ] . num_rows( ) , 1 ) ;
15221537
1523- // let col = batches[0].column_by_name("x").unwrap();
1524- // let int64_arr = col.as_any().downcast_ref::<Int64Array>().unwrap();
1525- // assert_eq!(int64_arr.value(0), 1);
1526- //
1527- // let col = batches[0].column_by_name("y").unwrap();
1528- // let int64_arr = col.as_any().downcast_ref::<Int64Array>().unwrap();
1529- // assert_eq!(int64_arr.value(0), 2);
1538+ let col = batches[ 0 ] . column_by_name ( "x" ) . unwrap ( ) ;
1539+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1540+ assert_eq ! ( int64_arr. value( 0 ) , 1 ) ;
1541+
1542+ let col = batches[ 0 ] . column_by_name ( "y" ) . unwrap ( ) ;
1543+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1544+ assert_eq ! ( int64_arr. value( 0 ) , 4 ) ;
1545+ }
1546+
1547+ #[ tokio:: test]
1548+ async fn test_limit_higher_than_total_rows ( ) {
1549+ let mut fixture = TableTestFixture :: new ( ) ;
1550+ fixture. setup_manifest_files ( ) . await ;
1551+
1552+ // Filter: y < 3
1553+ let mut builder = fixture. table . scan ( ) ;
1554+ let predicate = Reference :: new ( "y" ) . greater_than ( Datum :: long ( 3 ) ) ;
1555+ builder = builder
1556+ . with_filter ( predicate)
1557+ . with_limit ( Some ( 100_000_000 ) )
1558+ . with_row_selection_enabled ( true ) ;
1559+ let table_scan = builder. build ( ) . unwrap ( ) ;
1560+
1561+ let batch_stream = table_scan. to_arrow ( ) . await . unwrap ( ) ;
1562+
1563+ let batches: Vec < _ > = batch_stream. try_collect ( ) . await . unwrap ( ) ;
1564+
1565+ assert_eq ! ( batches. len( ) , 2 ) ;
1566+ assert_eq ! ( batches[ 0 ] . num_rows( ) , 312 ) ;
1567+ assert_eq ! ( batches[ 1 ] . num_rows( ) , 312 ) ;
1568+
1569+ let col = batches[ 0 ] . column_by_name ( "x" ) . unwrap ( ) ;
1570+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1571+ assert_eq ! ( int64_arr. value( 0 ) , 1 ) ;
1572+
1573+ let col = batches[ 0 ] . column_by_name ( "y" ) . unwrap ( ) ;
1574+ let int64_arr = col. as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ;
1575+ assert_eq ! ( int64_arr. value( 0 ) , 4 ) ;
15301576 }
15311577
15321578 #[ tokio:: test]
0 commit comments