@@ -1532,6 +1532,38 @@ mod tests {
15321532 assert_eq ! ( id. values( ) , & [ 4 , 5 , 6 , 7 , 2 , 3 , 0 , 1 ] ) ;
15331533 }
15341534
1535+ #[ tokio:: test]
1536+ async fn test_alltypes_with_empty_schema_large_batch ( ) {
1537+ // With an empty reader schema -- should count rows but produce no columns
1538+ let file = arrow_test_data ( "avro/alltypes_plain.avro" ) ;
1539+ let schema = Arc :: new ( Schema :: new ( Vec :: < Field > :: new ( ) ) ) ;
1540+ let batches = read_async_file ( & file, 1024 , None , Some ( schema) , None )
1541+ . await
1542+ . unwrap ( ) ;
1543+ assert_eq ! ( batches. len( ) , 1 ) ;
1544+ let batch = & batches[ 0 ] ;
1545+
1546+ assert_eq ! ( batch. num_rows( ) , 8 ) ;
1547+ assert_eq ! ( batch. num_columns( ) , 0 ) ;
1548+ }
1549+
1550+ #[ tokio:: test]
1551+ async fn test_alltypes_with_empty_schema_small_batch ( ) {
1552+ // With an empty reader schema -- should count rows but produce no columns
1553+ let file = arrow_test_data ( "avro/alltypes_plain.avro" ) ;
1554+ let schema = Arc :: new ( Schema :: new ( Vec :: < Field > :: new ( ) ) ) ;
1555+ let batches = read_async_file ( & file, 5 , None , Some ( schema) , None )
1556+ . await
1557+ . unwrap ( ) ;
1558+
1559+ assert_eq ! ( batches. len( ) , 2 ) ;
1560+
1561+ assert_eq ! ( batches[ 0 ] . num_rows( ) , 5 ) ;
1562+ assert_eq ! ( batches[ 0 ] . num_columns( ) , 0 ) ;
1563+ assert_eq ! ( batches[ 1 ] . num_rows( ) , 3 ) ;
1564+ assert_eq ! ( batches[ 1 ] . num_columns( ) , 0 ) ;
1565+ }
1566+
15351567 #[ tokio:: test]
15361568 async fn test_nested_no_schema_no_projection ( ) {
15371569 // No reader schema, no projection
@@ -1597,6 +1629,31 @@ mod tests {
15971629 assert_eq ! ( batch. schema( ) . field( 2 ) . name( ) , "f1" ) ;
15981630 }
15991631
1632+ #[ tokio:: test]
1633+ async fn test_nested_with_empty_schema ( ) {
1634+ // With an empty reader schema -- should count rows but produce no columns
1635+ let file = arrow_test_data ( "avro/nested_records.avro" ) ;
1636+ let schema = Arc :: new (
1637+ Schema :: new ( Vec :: < Field > :: new ( ) ) . with_metadata ( HashMap :: from ( [ (
1638+ SCHEMA_METADATA_KEY . into ( ) ,
1639+ r#"{
1640+ "type": "record",
1641+ "namespace": "ns1",
1642+ "name": "record1",
1643+ "fields": []
1644+ }"#
1645+ . to_owned ( ) ,
1646+ ) ] ) ) ,
1647+ ) ;
1648+ let batches = read_async_file ( & file, 1024 , None , Some ( schema) , None )
1649+ . await
1650+ . unwrap ( ) ;
1651+ let batch = & batches[ 0 ] ;
1652+
1653+ assert_eq ! ( batch. num_rows( ) , 2 ) ;
1654+ assert_eq ! ( batch. num_columns( ) , 0 ) ;
1655+ }
1656+
16001657 #[ tokio:: test]
16011658 async fn test_projection_error_out_of_bounds ( ) {
16021659 let file = arrow_test_data ( "avro/alltypes_plain.avro" ) ;
0 commit comments