@@ -29,9 +29,9 @@ use tokio::fs::File;
29
29
use tokio:: io:: { AsyncReadExt , AsyncWriteExt } ;
30
30
use tokio_stream:: Stream ;
31
31
32
- use databend_client:: APIClient ;
33
32
use databend_client:: PresignedResponse ;
34
33
use databend_client:: QueryResponse ;
34
+ use databend_client:: { APIClient , SchemaField } ;
35
35
use databend_driver_core:: error:: { Error , Result } ;
36
36
use databend_driver_core:: rows:: { Row , RowIterator , RowStatsIterator , RowWithStats , ServerStats } ;
37
37
use databend_driver_core:: schema:: { Schema , SchemaRef } ;
@@ -221,8 +221,14 @@ impl<'o> RestAPIConnection {
221
221
} )
222
222
}
223
223
224
- async fn wait_for_schema ( & self , resp : QueryResponse ) -> Result < QueryResponse > {
225
- if !resp. data . is_empty ( ) || !resp. schema . is_empty ( ) || resp. stats . progresses . has_progress ( )
224
+ async fn wait_for_schema (
225
+ & self ,
226
+ resp : QueryResponse ,
227
+ return_on_progress : bool ,
228
+ ) -> Result < QueryResponse > {
229
+ if !resp. data . is_empty ( )
230
+ || !resp. schema . is_empty ( )
231
+ || ( return_on_progress && resp. stats . progresses . has_progress ( ) )
226
232
{
227
233
return Ok ( resp) ;
228
234
}
@@ -240,7 +246,7 @@ impl<'o> RestAPIConnection {
240
246
241
247
if !result. data . is_empty ( )
242
248
|| !result. schema . is_empty ( )
243
- || result. stats . progresses . has_progress ( )
249
+ || ( return_on_progress && result. stats . progresses . has_progress ( ) )
244
250
{
245
251
break ;
246
252
}
@@ -262,6 +268,12 @@ impl<'o> RestAPIConnection {
262
268
fn default_copy_options ( ) -> BTreeMap < & ' o str , & ' o str > {
263
269
vec ! [ ( "purge" , "true" ) ] . into_iter ( ) . collect ( )
264
270
}
271
+
272
+ pub async fn query_row_batch ( & self , sql : & str ) -> Result < RowBatch > {
273
+ let resp = self . client . start_query ( sql) . await ?;
274
+ let resp = self . wait_for_schema ( resp, false ) . await ?;
275
+ RowBatch :: from_response ( self . client . clone ( ) , resp)
276
+ }
265
277
}
266
278
267
279
type PageFut = Pin < Box < dyn Future < Output = Result < QueryResponse > > + Send > > ;
0 commit comments