@@ -79,7 +79,7 @@ pub async fn ingest(req: HttpRequest, Json(json): Json<Value>) -> Result<HttpRes
79
79
80
80
pub async fn ingest_internal_stream ( stream_name : String , body : Bytes ) -> Result < ( ) , PostError > {
81
81
let size: usize = body. len ( ) ;
82
- let parsed_timestamp = Utc :: now ( ) . naive_utc ( ) ;
82
+ let now = Utc :: now ( ) ;
83
83
let ( rb, is_first) = {
84
84
let body_val: Value = serde_json:: from_slice ( & body) ?;
85
85
let hash_map = PARSEABLE . streams . read ( ) . unwrap ( ) ;
@@ -93,15 +93,15 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
93
93
. clone ( ) ;
94
94
let event = format:: json:: Event { data : body_val } ;
95
95
// For internal streams, use old schema
96
- event. into_recordbatch ( & schema, false , None , SchemaVersion :: V0 ) ?
96
+ event. into_recordbatch ( & schema, now , false , None , SchemaVersion :: V0 ) ?
97
97
} ;
98
98
event:: Event {
99
99
rb,
100
100
stream_name,
101
101
origin_format : "json" ,
102
102
origin_size : size as u64 ,
103
103
is_first_event : is_first,
104
- parsed_timestamp,
104
+ parsed_timestamp : now . naive_utc ( ) ,
105
105
time_partition : None ,
106
106
custom_partition_values : HashMap :: new ( ) ,
107
107
stream_type : StreamType :: Internal ,
@@ -351,6 +351,7 @@ mod tests {
351
351
use arrow:: datatypes:: Int64Type ;
352
352
use arrow_array:: { ArrayRef , Float64Array , Int64Array , ListArray , StringArray } ;
353
353
use arrow_schema:: { DataType , Field } ;
354
+ use chrono:: Utc ;
354
355
use serde_json:: json;
355
356
use std:: { collections:: HashMap , sync:: Arc } ;
356
357
@@ -392,8 +393,15 @@ mod tests {
392
393
"b" : "hello" ,
393
394
} ) ;
394
395
395
- let ( rb, _) =
396
- into_event_batch ( json, HashMap :: default ( ) , false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
396
+ let ( rb, _) = into_event_batch (
397
+ json,
398
+ HashMap :: default ( ) ,
399
+ Utc :: now ( ) ,
400
+ false ,
401
+ None ,
402
+ SchemaVersion :: V0 ,
403
+ )
404
+ . unwrap ( ) ;
397
405
398
406
assert_eq ! ( rb. num_rows( ) , 1 ) ;
399
407
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -419,8 +427,15 @@ mod tests {
419
427
"c" : null
420
428
} ) ;
421
429
422
- let ( rb, _) =
423
- into_event_batch ( json, HashMap :: default ( ) , false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
430
+ let ( rb, _) = into_event_batch (
431
+ json,
432
+ HashMap :: default ( ) ,
433
+ Utc :: now ( ) ,
434
+ false ,
435
+ None ,
436
+ SchemaVersion :: V0 ,
437
+ )
438
+ . unwrap ( ) ;
424
439
425
440
assert_eq ! ( rb. num_rows( ) , 1 ) ;
426
441
assert_eq ! ( rb. num_columns( ) , 3 ) ;
@@ -450,7 +465,8 @@ mod tests {
450
465
. into_iter ( ) ,
451
466
) ;
452
467
453
- let ( rb, _) = into_event_batch ( json, schema, false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
468
+ let ( rb, _) =
469
+ into_event_batch ( json, schema, Utc :: now ( ) , false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
454
470
455
471
assert_eq ! ( rb. num_rows( ) , 1 ) ;
456
472
assert_eq ! ( rb. num_columns( ) , 3 ) ;
@@ -480,7 +496,9 @@ mod tests {
480
496
. into_iter ( ) ,
481
497
) ;
482
498
483
- assert ! ( into_event_batch( json, schema, false , None , SchemaVersion :: V0 , ) . is_err( ) ) ;
499
+ assert ! (
500
+ into_event_batch( json, schema, Utc :: now( ) , false , None , SchemaVersion :: V0 , ) . is_err( )
501
+ ) ;
484
502
}
485
503
486
504
#[ test]
@@ -496,7 +514,8 @@ mod tests {
496
514
. into_iter ( ) ,
497
515
) ;
498
516
499
- let ( rb, _) = into_event_batch ( json, schema, false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
517
+ let ( rb, _) =
518
+ into_event_batch ( json, schema, Utc :: now ( ) , false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
500
519
501
520
assert_eq ! ( rb. num_rows( ) , 1 ) ;
502
521
assert_eq ! ( rb. num_columns( ) , 1 ) ;
@@ -535,8 +554,15 @@ mod tests {
535
554
} ,
536
555
] ) ;
537
556
538
- let ( rb, _) =
539
- into_event_batch ( json, HashMap :: default ( ) , false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
557
+ let ( rb, _) = into_event_batch (
558
+ json,
559
+ HashMap :: default ( ) ,
560
+ Utc :: now ( ) ,
561
+ false ,
562
+ None ,
563
+ SchemaVersion :: V0 ,
564
+ )
565
+ . unwrap ( ) ;
540
566
541
567
assert_eq ! ( rb. num_rows( ) , 3 ) ;
542
568
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -582,8 +608,15 @@ mod tests {
582
608
} ,
583
609
] ) ;
584
610
585
- let ( rb, _) =
586
- into_event_batch ( json, HashMap :: default ( ) , false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
611
+ let ( rb, _) = into_event_batch (
612
+ json,
613
+ HashMap :: default ( ) ,
614
+ Utc :: now ( ) ,
615
+ false ,
616
+ None ,
617
+ SchemaVersion :: V0 ,
618
+ )
619
+ . unwrap ( ) ;
587
620
588
621
assert_eq ! ( rb. num_rows( ) , 3 ) ;
589
622
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -630,7 +663,8 @@ mod tests {
630
663
. into_iter ( ) ,
631
664
) ;
632
665
633
- let ( rb, _) = into_event_batch ( json, schema, false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
666
+ let ( rb, _) =
667
+ into_event_batch ( json, schema, Utc :: now ( ) , false , None , SchemaVersion :: V0 ) . unwrap ( ) ;
634
668
635
669
assert_eq ! ( rb. num_rows( ) , 3 ) ;
636
670
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -677,7 +711,9 @@ mod tests {
677
711
. into_iter ( ) ,
678
712
) ;
679
713
680
- assert ! ( into_event_batch( json, schema, false , None , SchemaVersion :: V0 , ) . is_err( ) ) ;
714
+ assert ! (
715
+ into_event_batch( json, schema, Utc :: now( ) , false , None , SchemaVersion :: V0 , ) . is_err( )
716
+ ) ;
681
717
}
682
718
683
719
#[ test]
@@ -718,6 +754,7 @@ mod tests {
718
754
let ( rb, _) = into_event_batch (
719
755
flattened_json,
720
756
HashMap :: default ( ) ,
757
+ Utc :: now ( ) ,
721
758
false ,
722
759
None ,
723
760
SchemaVersion :: V0 ,
@@ -806,6 +843,7 @@ mod tests {
806
843
let ( rb, _) = into_event_batch (
807
844
flattened_json,
808
845
HashMap :: default ( ) ,
846
+ Utc :: now ( ) ,
809
847
false ,
810
848
None ,
811
849
SchemaVersion :: V1 ,
0 commit comments