@@ -20,11 +20,10 @@ use std::sync::Arc;
2020use arrow_array:: builder:: { MapBuilder , PrimitiveBuilder , StringBuilder } ;
2121use arrow_array:: types:: { Int64Type , TimestampMillisecondType } ;
2222use arrow_array:: RecordBatch ;
23- use arrow_schema:: { DataType , Field , Schema , SchemaRef , TimeUnit } ;
23+ use arrow_schema:: { DataType , Field , Schema , TimeUnit } ;
2424use futures:: StreamExt ;
2525
2626use crate :: scan:: ArrowRecordBatchStream ;
27- use crate :: spec:: TableMetadata ;
2827use crate :: table:: Table ;
2928use crate :: Result ;
3029
@@ -77,42 +76,38 @@ impl<'a> SnapshotsTable<'a> {
7776 let arrow_schema = Arc :: new ( self . schema ( ) ) ;
7877 let table_metadata = self . table . metadata_ref ( ) ;
7978
80- Ok (
81- futures:: stream:: once ( async move { Self :: build_batch ( arrow_schema, & table_metadata) } )
82- . boxed ( ) ,
83- )
84- }
85-
86- fn build_batch ( arrow_schema : SchemaRef , table_metadata : & TableMetadata ) -> Result < RecordBatch > {
87- let mut committed_at =
88- PrimitiveBuilder :: < TimestampMillisecondType > :: new ( ) . with_timezone ( "+00:00" ) ;
89- let mut snapshot_id = PrimitiveBuilder :: < Int64Type > :: new ( ) ;
90- let mut parent_id = PrimitiveBuilder :: < Int64Type > :: new ( ) ;
91- let mut operation = StringBuilder :: new ( ) ;
92- let mut manifest_list = StringBuilder :: new ( ) ;
93- let mut summary = MapBuilder :: new ( None , StringBuilder :: new ( ) , StringBuilder :: new ( ) ) ;
94-
95- for snapshot in table_metadata. snapshots ( ) {
96- committed_at. append_value ( snapshot. timestamp_ms ( ) ) ;
97- snapshot_id. append_value ( snapshot. snapshot_id ( ) ) ;
98- parent_id. append_option ( snapshot. parent_snapshot_id ( ) ) ;
99- manifest_list. append_value ( snapshot. manifest_list ( ) ) ;
100- operation. append_value ( snapshot. summary ( ) . operation . as_str ( ) ) ;
101- for ( key, value) in & snapshot. summary ( ) . additional_properties {
102- summary. keys ( ) . append_value ( key) ;
103- summary. values ( ) . append_value ( value) ;
79+ Ok ( futures:: stream:: once ( async move {
80+ let mut committed_at =
81+ PrimitiveBuilder :: < TimestampMillisecondType > :: new ( ) . with_timezone ( "+00:00" ) ;
82+ let mut snapshot_id = PrimitiveBuilder :: < Int64Type > :: new ( ) ;
83+ let mut parent_id = PrimitiveBuilder :: < Int64Type > :: new ( ) ;
84+ let mut operation = StringBuilder :: new ( ) ;
85+ let mut manifest_list = StringBuilder :: new ( ) ;
86+ let mut summary = MapBuilder :: new ( None , StringBuilder :: new ( ) , StringBuilder :: new ( ) ) ;
87+
88+ for snapshot in table_metadata. snapshots ( ) {
89+ committed_at. append_value ( snapshot. timestamp_ms ( ) ) ;
90+ snapshot_id. append_value ( snapshot. snapshot_id ( ) ) ;
91+ parent_id. append_option ( snapshot. parent_snapshot_id ( ) ) ;
92+ manifest_list. append_value ( snapshot. manifest_list ( ) ) ;
93+ operation. append_value ( snapshot. summary ( ) . operation . as_str ( ) ) ;
94+ for ( key, value) in & snapshot. summary ( ) . additional_properties {
95+ summary. keys ( ) . append_value ( key) ;
96+ summary. values ( ) . append_value ( value) ;
97+ }
98+ summary. append ( true ) ?;
10499 }
105- summary. append ( true ) ?;
106- }
107100
108- Ok ( RecordBatch :: try_new ( arrow_schema, vec ! [
109- Arc :: new( committed_at. finish( ) ) ,
110- Arc :: new( snapshot_id. finish( ) ) ,
111- Arc :: new( parent_id. finish( ) ) ,
112- Arc :: new( operation. finish( ) ) ,
113- Arc :: new( manifest_list. finish( ) ) ,
114- Arc :: new( summary. finish( ) ) ,
115- ] ) ?)
101+ Ok ( RecordBatch :: try_new ( arrow_schema, vec ! [
102+ Arc :: new( committed_at. finish( ) ) ,
103+ Arc :: new( snapshot_id. finish( ) ) ,
104+ Arc :: new( parent_id. finish( ) ) ,
105+ Arc :: new( operation. finish( ) ) ,
106+ Arc :: new( manifest_list. finish( ) ) ,
107+ Arc :: new( summary. finish( ) ) ,
108+ ] ) ?)
109+ } )
110+ . boxed ( ) )
116111 }
117112}
118113
0 commit comments