@@ -31,7 +31,7 @@ use crate::{
3131 storage:: StreamType ,
3232 LOCK_EXPECT ,
3333} ;
34- use chrono:: NaiveDateTime ;
34+ use chrono:: { NaiveDateTime , Utc } ;
3535use std:: collections:: HashMap ;
3636
3737pub const DEFAULT_TIMESTAMP_KEY : & str = "p_timestamp" ;
@@ -47,7 +47,7 @@ pub struct Event {
4747 pub origin_size : u64 ,
4848 pub is_first_event : bool ,
4949 pub parsed_timestamp : NaiveDateTime ,
50- pub time_partition : Option < String > ,
50+ pub time_partitioned : bool ,
5151 pub custom_partition_values : HashMap < String , String > ,
5252 pub stream_type : StreamType ,
5353}
@@ -56,12 +56,14 @@ pub struct Event {
5656impl Event {
5757 pub fn process ( self ) -> Result < ( ) , EventError > {
5858 let mut key = get_schema_key ( & self . rb . schema ( ) . fields ) ;
59- if self . time_partition . is_some ( ) {
60- let parsed_timestamp_to_min = self . parsed_timestamp . format ( "%Y%m%dT%H%M" ) . to_string ( ) ;
61- key. push_str ( & parsed_timestamp_to_min) ;
59+ if self . time_partitioned {
60+ // For time partitioned streams, concatenate timestamp to filename, ensuring we don't write to a finished arrows file
61+ let curr_timestamp = Utc :: now ( ) . format ( "%Y%m%dT%H%M" ) . to_string ( ) ;
62+ key. push_str ( & curr_timestamp) ;
6263 }
6364
6465 if !self . custom_partition_values . is_empty ( ) {
66+ // For custom partitioned streams, concatenate values to filename, ensuring we write to different arrows files
6567 for ( k, v) in self . custom_partition_values . iter ( ) . sorted_by_key ( |v| v. 0 ) {
6668 key. push_str ( & format ! ( "&{k}={v}" ) ) ;
6769 }
0 commit comments