@@ -99,7 +99,14 @@ async fn push_logs(stream_name: String, req: HttpRequest, body: Bytes) -> Result
9999 . ok_or ( PostError :: StreamNotFound ( stream_name. clone ( ) ) ) ?
100100 . schema
101101 . clone ( ) ;
102- into_event_batch ( req, body, schema) ?
102+
103+ let time_partition = hash_map
104+ . get ( & stream_name)
105+ . ok_or ( PostError :: StreamNotFound ( stream_name. clone ( ) ) ) ?
106+ . time_partition
107+ . clone ( ) ;
108+
109+ into_event_batch ( req, body, schema, time_partition) ?
103110 } ;
104111
105112 event:: Event {
@@ -119,6 +126,7 @@ fn into_event_batch(
119126 req : HttpRequest ,
120127 body : Bytes ,
121128 schema : HashMap < String , Arc < Field > > ,
129+ time_partition : Option < String > ,
122130) -> Result < ( usize , arrow_array:: RecordBatch , bool ) , PostError > {
123131 let tags = collect_labelled_headers ( & req, PREFIX_TAGS , SEPARATOR ) ?;
124132 let metadata = collect_labelled_headers ( & req, PREFIX_META , SEPARATOR ) ?;
@@ -129,7 +137,7 @@ fn into_event_batch(
129137 tags,
130138 metadata,
131139 } ;
132- let ( rb, is_first) = event. into_recordbatch ( schema) ?;
140+ let ( rb, is_first) = event. into_recordbatch ( schema, time_partition ) ?;
133141 Ok ( ( size, rb, is_first) )
134142}
135143
@@ -138,7 +146,7 @@ pub async fn create_stream_if_not_exists(stream_name: &str) -> Result<(), PostEr
138146 if STREAM_INFO . stream_exists ( stream_name) {
139147 return Ok ( ( ) ) ;
140148 }
141- super :: logstream:: create_stream ( stream_name. to_string ( ) ) . await ?;
149+ super :: logstream:: create_stream ( stream_name. to_string ( ) , "" ) . await ?;
142150 Ok ( ( ) )
143151}
144152
@@ -241,6 +249,7 @@ mod tests {
241249 req,
242250 Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
243251 HashMap :: default ( ) ,
252+ None ,
244253 )
245254 . unwrap ( ) ;
246255
@@ -287,6 +296,7 @@ mod tests {
287296 req,
288297 Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
289298 HashMap :: default ( ) ,
299+ None ,
290300 )
291301 . unwrap ( ) ;
292302
@@ -320,8 +330,13 @@ mod tests {
320330
321331 let req = TestRequest :: default ( ) . to_http_request ( ) ;
322332
323- let ( _, rb, _) =
324- into_event_batch ( req, Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) , schema) . unwrap ( ) ;
333+ let ( _, rb, _) = into_event_batch (
334+ req,
335+ Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
336+ schema,
337+ None ,
338+ )
339+ . unwrap ( ) ;
325340
326341 assert_eq ! ( rb. num_rows( ) , 1 ) ;
327342 assert_eq ! ( rb. num_columns( ) , 5 ) ;
@@ -353,10 +368,13 @@ mod tests {
353368
354369 let req = TestRequest :: default ( ) . to_http_request ( ) ;
355370
356- assert ! (
357- into_event_batch( req, Bytes :: from( serde_json:: to_vec( & json) . unwrap( ) ) , schema, )
358- . is_err( )
359- ) ;
371+ assert ! ( into_event_batch(
372+ req,
373+ Bytes :: from( serde_json:: to_vec( & json) . unwrap( ) ) ,
374+ schema,
375+ None
376+ )
377+ . is_err( ) ) ;
360378 }
361379
362380 #[ test]
@@ -374,8 +392,13 @@ mod tests {
374392
375393 let req = TestRequest :: default ( ) . to_http_request ( ) ;
376394
377- let ( _, rb, _) =
378- into_event_batch ( req, Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) , schema) . unwrap ( ) ;
395+ let ( _, rb, _) = into_event_batch (
396+ req,
397+ Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
398+ schema,
399+ None ,
400+ )
401+ . unwrap ( ) ;
379402
380403 assert_eq ! ( rb. num_rows( ) , 1 ) ;
381404 assert_eq ! ( rb. num_columns( ) , 3 ) ;
@@ -391,6 +414,7 @@ mod tests {
391414 req,
392415 Bytes :: from( serde_json:: to_vec( & json) . unwrap( ) ) ,
393416 HashMap :: default ( ) ,
417+ None
394418 )
395419 . is_err( ) )
396420 }
@@ -419,6 +443,7 @@ mod tests {
419443 req,
420444 Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
421445 HashMap :: default ( ) ,
446+ None ,
422447 )
423448 . unwrap ( ) ;
424449
@@ -472,6 +497,7 @@ mod tests {
472497 req,
473498 Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
474499 HashMap :: default ( ) ,
500+ None ,
475501 )
476502 . unwrap ( ) ;
477503
@@ -521,8 +547,13 @@ mod tests {
521547 ) ;
522548 let req = TestRequest :: default ( ) . to_http_request ( ) ;
523549
524- let ( _, rb, _) =
525- into_event_batch ( req, Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) , schema) . unwrap ( ) ;
550+ let ( _, rb, _) = into_event_batch (
551+ req,
552+ Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
553+ schema,
554+ None ,
555+ )
556+ . unwrap ( ) ;
526557
527558 assert_eq ! ( rb. num_rows( ) , 3 ) ;
528559 assert_eq ! ( rb. num_columns( ) , 6 ) ;
@@ -566,6 +597,7 @@ mod tests {
566597 req,
567598 Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
568599 HashMap :: default ( ) ,
600+ None ,
569601 )
570602 . unwrap ( ) ;
571603
@@ -612,10 +644,13 @@ mod tests {
612644 . into_iter ( ) ,
613645 ) ;
614646
615- assert ! (
616- into_event_batch( req, Bytes :: from( serde_json:: to_vec( & json) . unwrap( ) ) , schema, )
617- . is_err( )
618- ) ;
647+ assert ! ( into_event_batch(
648+ req,
649+ Bytes :: from( serde_json:: to_vec( & json) . unwrap( ) ) ,
650+ schema,
651+ None
652+ )
653+ . is_err( ) ) ;
619654 }
620655
621656 #[ test]
@@ -647,6 +682,7 @@ mod tests {
647682 req,
648683 Bytes :: from ( serde_json:: to_vec ( & json) . unwrap ( ) ) ,
649684 HashMap :: default ( ) ,
685+ None ,
650686 )
651687 . unwrap ( ) ;
652688
0 commit comments