@@ -10,13 +10,11 @@ use datafusion::arrow::array::{
10
10
use datafusion:: arrow:: datatypes:: { DataType , Field , SchemaRef } ;
11
11
use datafusion:: arrow:: ipc:: reader:: FileReader ;
12
12
use datafusion:: catalog:: streaming:: StreamingTable ;
13
- use datafusion:: catalog:: { CatalogProviderList , SchemaProvider } ;
13
+ use datafusion:: catalog:: { CatalogProviderList , MemTable , SchemaProvider } ;
14
14
use datafusion:: common:: utils:: SingleRowListArrayBuilder ;
15
15
use datafusion:: datasource:: { TableProvider , ViewTable } ;
16
16
use datafusion:: error:: { DataFusionError , Result } ;
17
- use datafusion:: execution:: { SendableRecordBatchStream , TaskContext } ;
18
17
use datafusion:: logical_expr:: { ColumnarValue , ScalarUDF , Volatility } ;
19
- use datafusion:: physical_plan:: stream:: RecordBatchStreamAdapter ;
20
18
use datafusion:: physical_plan:: streaming:: PartitionStream ;
21
19
use datafusion:: prelude:: { create_udf, SessionContext } ;
22
20
use postgres_types:: Oid ;
@@ -394,19 +392,10 @@ impl ArrowTable {
394
392
data : batches,
395
393
} )
396
394
}
397
- }
398
-
399
- impl PartitionStream for ArrowTable {
400
- fn schema ( & self ) -> & SchemaRef {
401
- & self . schema
402
- }
403
395
404
- fn execute ( & self , _ctx : Arc < TaskContext > ) -> SendableRecordBatchStream {
405
- let data = self . data . clone ( ) ;
406
- Box :: pin ( RecordBatchStreamAdapter :: new (
407
- self . schema . clone ( ) ,
408
- futures:: stream:: iter ( data. into_iter ( ) . map ( Ok ) ) ,
409
- ) )
396
+ /// Convert the arrow data into datafusion MemTable
397
+ pub fn try_into_memtable ( self ) -> Result < MemTable > {
398
+ MemTable :: try_new ( self . schema , vec ! [ self . data] )
410
399
}
411
400
}
412
401
@@ -664,8 +653,8 @@ impl PgCatalogStaticTables {
664
653
/// Create table from dumped arrow data
665
654
fn create_arrow_table ( data_bytes : Vec < u8 > ) -> Result < Arc < dyn TableProvider > > {
666
655
let table = ArrowTable :: from_ipc_data ( data_bytes) ?;
667
- let streaming_table = StreamingTable :: try_new ( table. schema . clone ( ) , vec ! [ Arc :: new ( table ) ] ) ?;
668
- Ok ( Arc :: new ( streaming_table ) )
656
+ let mem_table = table. try_into_memtable ( ) ?;
657
+ Ok ( Arc :: new ( mem_table ) )
669
658
}
670
659
}
671
660
0 commit comments