@@ -3840,6 +3840,53 @@ async fn native_batch_direct_and_async_use_aggregate_counts() {
38403840 assert_eq ! ( attached. num_modified_rows( ) , None ) ;
38413841 assert_eq ! ( native_batch_requests( & server) . await . len( ) , 1 ) ;
38423842 }
3843+
3844+ for ( last_count, expected) in [ ( 4 , Some ( 6 ) ) , ( -2 , None ) ] {
3845+ let server = MockServer :: start ( ) . await ;
3846+ mount_create_session ( & server) . await ;
3847+ mount_close_any_statement ( & server) . await ;
3848+ let first = native_batch_counts ( vec ! [ Some ( 2 ) ] , None ) ;
3849+ let last = native_batch_counts ( vec ! [ Some ( last_count) ] , None ) ;
3850+ let mut body: serde_json:: Value =
3851+ serde_json:: from_str ( & succeeded_inline_body ( "batch-paged" , & first) ) . unwrap ( ) ;
3852+ body[ "manifest" ] [ "total_chunk_count" ] = json ! ( 2 ) ;
3853+ body[ "manifest" ] [ "total_row_count" ] = json ! ( 2 ) ;
3854+ body[ "result" ] [ "next_chunk_index" ] = json ! ( 1 ) ;
3855+ mount_execute ( & server, running_body ( "batch-paged" ) ) . await ;
3856+ mount_status ( & server, "batch-paged" , body. to_string ( ) ) . await ;
3857+ Mock :: given ( method ( "GET" ) )
3858+ . and ( path ( "/api/2.0/sql/statements/batch-paged/result/chunks/1" ) )
3859+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
3860+ "chunk_index" : 1 , "row_offset" : 1 , "row_count" : 1 ,
3861+ "attachment" : STANDARD . encode( arrow_ipc_bytes( & last) ) ,
3862+ } ) ) )
3863+ . mount ( & server)
3864+ . await ;
3865+ let session = open_session ( & server) . await ;
3866+ let mut statement = session. statement ( ) ;
3867+ statement. spec ( ) . sql ( "INSERT INTO t VALUES (?)" ) ;
3868+ for value in [ 11 , 29 ] {
3869+ statement
3870+ . spec ( )
3871+ . param ( 1 , TypedValue :: Int64 ( value) )
3872+ . unwrap ( )
3873+ . add_parameter_set ( ) ;
3874+ }
3875+ let executed = statement. submit ( ) . await . unwrap ( ) ;
3876+ executed. status ( ) . await . unwrap ( ) ;
3877+ assert_eq ! ( executed. num_modified_rows( ) , None ) ;
3878+ let _stream = executed. await_result ( ) . await . unwrap ( ) ;
3879+ assert_eq ! ( executed. num_modified_rows( ) , expected) ;
3880+ assert_eq ! (
3881+ executed. reader( ) . unwrap( ) . num_modified_rows( ) . unwrap( ) ,
3882+ expected
3883+ ) ;
3884+ executed. status ( ) . await . unwrap ( ) ;
3885+ assert_eq ! ( executed. num_modified_rows( ) , expected) ;
3886+ let _stream = executed. fetch_result ( ) . await . unwrap ( ) ;
3887+ assert_eq ! ( executed. num_modified_rows( ) , expected) ;
3888+ assert_eq ! ( native_batch_requests( & server) . await . len( ) , 1 ) ;
3889+ }
38433890}
38443891
38453892#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
0 commit comments