@@ -138,6 +138,7 @@ impl EventFormat for Event {
138
138
// also extract the arrow schema, tags and metadata from the incoming json
139
139
fn to_data (
140
140
self ,
141
+ static_schema_flag : bool ,
141
142
stored_schema : & HashMap < String , Arc < Field > > ,
142
143
time_partition : Option < & String > ,
143
144
time_partition_limit : Option < NonZeroU32 > ,
@@ -203,6 +204,8 @@ impl EventFormat for Event {
203
204
) ) ;
204
205
}
205
206
207
+ let schema = Self :: prepare_and_validate_schema ( schema, & stored_schema, static_schema_flag) ?;
208
+
206
209
Ok ( ( flattened, schema, is_first) )
207
210
}
208
211
@@ -239,6 +242,7 @@ impl EventFormat for Event {
239
242
240
243
let p_timestamp = self . p_timestamp ;
241
244
let ( data, schema, is_first_event) = self . to_data (
245
+ static_schema_flag,
242
246
& storage_schema,
243
247
time_partition. as_ref ( ) ,
244
248
time_partition_limit,
@@ -265,9 +269,7 @@ impl EventFormat for Event {
265
269
let batch = Self :: into_recordbatch (
266
270
p_timestamp,
267
271
vec ! [ json] ,
268
- schema. clone ( ) ,
269
- & storage_schema,
270
- static_schema_flag,
272
+ & schema,
271
273
time_partition. as_ref ( ) ,
272
274
schema_version,
273
275
) ?;
@@ -507,6 +509,7 @@ mod tests {
507
509
let store_schema = HashMap :: default ( ) ;
508
510
let ( data, schema, _) = Event :: new ( json)
509
511
. to_data (
512
+ false ,
510
513
& store_schema,
511
514
None ,
512
515
None ,
@@ -515,16 +518,8 @@ mod tests {
515
518
& LogSource :: Json ,
516
519
)
517
520
. unwrap ( ) ;
518
- let rb = Event :: into_recordbatch (
519
- Utc :: now ( ) ,
520
- data,
521
- schema,
522
- & store_schema,
523
- false ,
524
- None ,
525
- SchemaVersion :: V0 ,
526
- )
527
- . unwrap ( ) ;
521
+ let rb =
522
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
528
523
529
524
assert_eq ! ( rb. num_rows( ) , 1 ) ;
530
525
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -553,6 +548,7 @@ mod tests {
553
548
let store_schema = HashMap :: default ( ) ;
554
549
let ( data, schema, _) = Event :: new ( json)
555
550
. to_data (
551
+ false ,
556
552
& store_schema,
557
553
None ,
558
554
None ,
@@ -561,16 +557,8 @@ mod tests {
561
557
& LogSource :: Json ,
562
558
)
563
559
. unwrap ( ) ;
564
- let rb = Event :: into_recordbatch (
565
- Utc :: now ( ) ,
566
- data,
567
- schema,
568
- & store_schema,
569
- false ,
570
- None ,
571
- SchemaVersion :: V0 ,
572
- )
573
- . unwrap ( ) ;
560
+ let rb =
561
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
574
562
575
563
assert_eq ! ( rb. num_rows( ) , 1 ) ;
576
564
assert_eq ! ( rb. num_columns( ) , 3 ) ;
@@ -601,6 +589,7 @@ mod tests {
601
589
) ;
602
590
let ( data, schema, _) = Event :: new ( json)
603
591
. to_data (
592
+ false ,
604
593
& store_schema,
605
594
None ,
606
595
None ,
@@ -609,16 +598,8 @@ mod tests {
609
598
& LogSource :: Json ,
610
599
)
611
600
. unwrap ( ) ;
612
- let rb = Event :: into_recordbatch (
613
- Utc :: now ( ) ,
614
- data,
615
- schema,
616
- & store_schema,
617
- false ,
618
- None ,
619
- SchemaVersion :: V0 ,
620
- )
621
- . unwrap ( ) ;
601
+ let rb =
602
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
622
603
623
604
assert_eq ! ( rb. num_rows( ) , 1 ) ;
624
605
assert_eq ! ( rb. num_columns( ) , 3 ) ;
@@ -650,6 +631,7 @@ mod tests {
650
631
651
632
assert ! ( Event :: new( json)
652
633
. to_data(
634
+ false ,
653
635
& store_schema,
654
636
None ,
655
637
None ,
@@ -675,6 +657,7 @@ mod tests {
675
657
676
658
let ( data, schema, _) = Event :: new ( json)
677
659
. to_data (
660
+ false ,
678
661
& store_schema,
679
662
None ,
680
663
None ,
@@ -683,16 +666,8 @@ mod tests {
683
666
& LogSource :: Json ,
684
667
)
685
668
. unwrap ( ) ;
686
- let rb = Event :: into_recordbatch (
687
- Utc :: now ( ) ,
688
- data,
689
- schema,
690
- & store_schema,
691
- false ,
692
- None ,
693
- SchemaVersion :: V0 ,
694
- )
695
- . unwrap ( ) ;
669
+ let rb =
670
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
696
671
697
672
assert_eq ! ( rb. num_rows( ) , 1 ) ;
698
673
assert_eq ! ( rb. num_columns( ) , 1 ) ;
@@ -719,6 +694,7 @@ mod tests {
719
694
let store_schema = HashMap :: new ( ) ;
720
695
let ( data, schema, _) = Event :: new ( json)
721
696
. to_data (
697
+ false ,
722
698
& store_schema,
723
699
None ,
724
700
None ,
@@ -727,16 +703,8 @@ mod tests {
727
703
& LogSource :: Json ,
728
704
)
729
705
. unwrap ( ) ;
730
- let rb = Event :: into_recordbatch (
731
- Utc :: now ( ) ,
732
- data,
733
- schema,
734
- & store_schema,
735
- false ,
736
- None ,
737
- SchemaVersion :: V0 ,
738
- )
739
- . unwrap ( ) ;
706
+ let rb =
707
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
740
708
741
709
assert_eq ! ( rb. num_rows( ) , 3 ) ;
742
710
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -785,6 +753,7 @@ mod tests {
785
753
let store_schema = HashMap :: new ( ) ;
786
754
let ( data, schema, _) = Event :: new ( json)
787
755
. to_data (
756
+ false ,
788
757
& store_schema,
789
758
None ,
790
759
None ,
@@ -793,16 +762,8 @@ mod tests {
793
762
& LogSource :: Json ,
794
763
)
795
764
. unwrap ( ) ;
796
- let rb = Event :: into_recordbatch (
797
- Utc :: now ( ) ,
798
- data,
799
- schema,
800
- & store_schema,
801
- false ,
802
- None ,
803
- SchemaVersion :: V0 ,
804
- )
805
- . unwrap ( ) ;
765
+ let rb =
766
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
806
767
807
768
assert_eq ! ( rb. num_rows( ) , 3 ) ;
808
769
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -850,6 +811,7 @@ mod tests {
850
811
) ;
851
812
let ( data, schema, _) = Event :: new ( json)
852
813
. to_data (
814
+ false ,
853
815
& store_schema,
854
816
None ,
855
817
None ,
@@ -858,16 +820,8 @@ mod tests {
858
820
& LogSource :: Json ,
859
821
)
860
822
. unwrap ( ) ;
861
- let rb = Event :: into_recordbatch (
862
- Utc :: now ( ) ,
863
- data,
864
- schema,
865
- & store_schema,
866
- false ,
867
- None ,
868
- SchemaVersion :: V0 ,
869
- )
870
- . unwrap ( ) ;
823
+ let rb =
824
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
871
825
872
826
assert_eq ! ( rb. num_rows( ) , 3 ) ;
873
827
assert_eq ! ( rb. num_columns( ) , 4 ) ;
@@ -916,6 +870,7 @@ mod tests {
916
870
917
871
assert ! ( Event :: new( json)
918
872
. to_data(
873
+ false ,
919
874
& store_schema,
920
875
None ,
921
876
None ,
@@ -953,6 +908,7 @@ mod tests {
953
908
let store_schema = HashMap :: new ( ) ;
954
909
let ( data, schema, _) = Event :: new ( json)
955
910
. to_data (
911
+ false ,
956
912
& store_schema,
957
913
None ,
958
914
None ,
@@ -961,16 +917,8 @@ mod tests {
961
917
& LogSource :: Json ,
962
918
)
963
919
. unwrap ( ) ;
964
- let rb = Event :: into_recordbatch (
965
- Utc :: now ( ) ,
966
- data,
967
- schema,
968
- & store_schema,
969
- false ,
970
- None ,
971
- SchemaVersion :: V0 ,
972
- )
973
- . unwrap ( ) ;
920
+ let rb =
921
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V0 ) . unwrap ( ) ;
974
922
975
923
assert_eq ! ( rb. num_rows( ) , 4 ) ;
976
924
assert_eq ! ( rb. num_columns( ) , 5 ) ;
@@ -1044,6 +992,7 @@ mod tests {
1044
992
let store_schema = HashMap :: new ( ) ;
1045
993
let ( data, schema, _) = Event :: new ( json)
1046
994
. to_data (
995
+ false ,
1047
996
& store_schema,
1048
997
None ,
1049
998
None ,
@@ -1052,16 +1001,8 @@ mod tests {
1052
1001
& LogSource :: Json ,
1053
1002
)
1054
1003
. unwrap ( ) ;
1055
- let rb = Event :: into_recordbatch (
1056
- Utc :: now ( ) ,
1057
- data,
1058
- schema,
1059
- & store_schema,
1060
- false ,
1061
- None ,
1062
- SchemaVersion :: V1 ,
1063
- )
1064
- . unwrap ( ) ;
1004
+ let rb =
1005
+ Event :: into_recordbatch ( Utc :: now ( ) , data, & schema, None , SchemaVersion :: V1 ) . unwrap ( ) ;
1065
1006
1066
1007
assert_eq ! ( rb. num_rows( ) , 4 ) ;
1067
1008
assert_eq ! ( rb. num_columns( ) , 5 ) ;
0 commit comments