@@ -43,10 +43,7 @@ use crate::{
43
43
metadata:: SchemaVersion ,
44
44
otel:: { logs:: flatten_otel_logs, metrics:: flatten_otel_metrics, traces:: flatten_otel_traces} ,
45
45
storage:: StreamType ,
46
- utils:: {
47
- arrow:: get_field,
48
- json:: { convert_array_to_object, flatten:: convert_to_array} ,
49
- } ,
46
+ utils:: { arrow:: get_field, json:: convert_array_to_object} ,
50
47
} ;
51
48
52
49
pub struct Event {
@@ -70,7 +67,7 @@ pub fn flatten_logs(
70
67
custom_partitions : Option < & String > ,
71
68
schema_version : SchemaVersion ,
72
69
log_source : & LogSource ,
73
- ) -> Result < Vec < Value > , anyhow :: Error > {
70
+ ) -> anyhow :: Result < Vec < Value > > {
74
71
let data = match log_source {
75
72
LogSource :: Kinesis => {
76
73
//custom flattening required for Amazon Kinesis
@@ -97,25 +94,14 @@ pub fn flatten_logs(
97
94
98
95
let mut logs = vec ! [ ] ;
99
96
for json in data {
100
- if time_partition. is_some ( ) || custom_partitions. is_some ( ) {
101
- logs. append ( & mut convert_array_to_object (
102
- json,
103
- time_partition,
104
- time_partition_limit,
105
- custom_partitions,
106
- schema_version,
107
- log_source,
108
- ) ?)
109
- } else {
110
- logs. push ( convert_to_array ( convert_array_to_object (
111
- json,
112
- None ,
113
- None ,
114
- None ,
115
- schema_version,
116
- log_source,
117
- ) ?) ?)
118
- }
97
+ logs. append ( & mut convert_array_to_object (
98
+ json,
99
+ time_partition,
100
+ time_partition_limit,
101
+ custom_partitions,
102
+ schema_version,
103
+ log_source,
104
+ ) ?)
119
105
}
120
106
121
107
Ok ( logs)
@@ -139,7 +125,7 @@ impl EventFormat for Event {
139
125
custom_partitions : Option < & String > ,
140
126
schema_version : SchemaVersion ,
141
127
log_source : & LogSource ,
142
- ) -> Result < ( Self :: Data , Vec < Arc < Field > > , bool ) , anyhow :: Error > {
128
+ ) -> anyhow :: Result < ( Self :: Data , Vec < Arc < Field > > , bool ) > {
143
129
let flattened = flatten_logs (
144
130
self . json ,
145
131
time_partition,
@@ -202,7 +188,7 @@ impl EventFormat for Event {
202
188
}
203
189
204
190
// Convert the Data type (defined above) to arrow record batch
205
- fn decode ( data : Self :: Data , schema : Arc < Schema > ) -> Result < RecordBatch , anyhow:: Error > {
191
+ fn decode ( data : Self :: Data , schema : Arc < Schema > ) -> anyhow:: Result < RecordBatch > {
206
192
let array_capacity = round_upto_multiple_of_64 ( data. len ( ) ) ;
207
193
let mut reader = ReaderBuilder :: new ( schema)
208
194
. with_batch_size ( array_capacity)
@@ -230,7 +216,7 @@ impl EventFormat for Event {
230
216
schema_version : SchemaVersion ,
231
217
log_source : & LogSource ,
232
218
stream_type : StreamType ,
233
- ) -> Result < super :: Event , anyhow :: Error > {
219
+ ) -> anyhow :: Result < super :: Event > {
234
220
let custom_partition_values = match custom_partitions. as_ref ( ) {
235
221
Some ( custom_partitions) => {
236
222
let custom_partitions = custom_partitions. split ( ',' ) . collect_vec ( ) ;
@@ -295,7 +281,7 @@ pub fn extract_custom_partition_values(
295
281
fn extract_and_parse_time (
296
282
json : & Value ,
297
283
time_partition : & str ,
298
- ) -> Result < NaiveDateTime , anyhow:: Error > {
284
+ ) -> anyhow:: Result < NaiveDateTime > {
299
285
let current_time = json
300
286
. get ( time_partition)
301
287
. ok_or_else ( || anyhow ! ( "Missing field for time partition in json: {time_partition}" ) ) ?;
0 commit comments