@@ -22,20 +22,20 @@ use std::{
22
22
sync:: Arc ,
23
23
} ;
24
24
25
+ use arrow:: error:: Result ;
25
26
use arrow_array:: { ArrayRef , RecordBatch , StringArray , TimestampMillisecondArray , UInt64Array } ;
26
- use arrow_schema:: { ArrowError , DataType , Field , Schema , TimeUnit } ;
27
+ use arrow_schema:: { DataType , Field , Schema , TimeUnit } ;
27
28
use arrow_select:: take:: take;
29
+ pub use batch_adapter:: adapt_batch;
28
30
use chrono:: { DateTime , Utc } ;
29
31
use itertools:: Itertools ;
30
-
31
- pub mod batch_adapter;
32
- pub mod flight;
33
-
34
- pub use batch_adapter:: adapt_batch;
35
32
use serde_json:: { Map , Value } ;
36
33
37
34
use crate :: event:: DEFAULT_TIMESTAMP_KEY ;
38
35
36
+ pub mod batch_adapter;
37
+ pub mod flight;
38
+
39
39
/// Converts a slice of record batches to JSON.
40
40
///
41
41
/// # Arguments
@@ -46,9 +46,10 @@ use crate::event::DEFAULT_TIMESTAMP_KEY;
46
46
/// * Result<Vec<Map<String, Value>>>
47
47
///
48
48
/// A vector of JSON objects representing the record batches.
49
- pub fn record_batches_to_json (
50
- records : & [ RecordBatch ] ,
51
- ) -> Result < Vec < Map < String , Value > > , ArrowError > {
49
+ ///
50
+ /// TODO: maybe this can be futher optimized by directly converting `arrow`
51
+ /// to an in-memory type instead of serializing to bytes.
52
+ pub fn record_batches_to_json ( records : & [ RecordBatch ] ) -> Result < Vec < Map < String , Value > > > {
52
53
let buf = vec ! [ ] ;
53
54
let mut writer = arrow_json:: ArrayWriter :: new ( buf) ;
54
55
for record in records {
@@ -101,7 +102,7 @@ pub fn add_parseable_fields(
101
102
rb : RecordBatch ,
102
103
p_timestamp : DateTime < Utc > ,
103
104
p_custom_fields : & HashMap < String , String > ,
104
- ) -> Result < RecordBatch , ArrowError > {
105
+ ) -> Result < RecordBatch > {
105
106
// Return Result for proper error handling
106
107
107
108
// Add custom fields in sorted order
0 commit comments