@@ -23,24 +23,18 @@ use std::{
23
23
} ;
24
24
25
25
use anyhow:: { anyhow, Error as AnyError } ;
26
- use arrow_array:: { RecordBatch , StringArray } ;
26
+ use arrow_array:: RecordBatch ;
27
27
use arrow_schema:: { DataType , Field , Schema , TimeUnit } ;
28
28
use chrono:: DateTime ;
29
29
use serde_json:: Value ;
30
30
31
- use crate :: {
32
- metadata:: SchemaVersion ,
33
- utils:: { self , arrow:: get_field} ,
34
- } ;
31
+ use crate :: { metadata:: SchemaVersion , utils:: arrow:: get_field} ;
35
32
36
- use super :: { DEFAULT_METADATA_KEY , DEFAULT_TAGS_KEY , DEFAULT_TIMESTAMP_KEY } ;
33
+ use super :: DEFAULT_TIMESTAMP_KEY ;
37
34
38
35
pub mod json;
39
36
40
37
static TIME_FIELD_NAME_PARTS : [ & str ; 2 ] = [ "time" , "date" ] ;
41
-
42
- type Tags = String ;
43
- type Metadata = String ;
44
38
type EventSchema = Vec < Arc < Field > > ;
45
39
46
40
/// Source of the logs, used to perform special processing for certain sources
@@ -87,7 +81,7 @@ pub trait EventFormat: Sized {
87
81
time_partition : Option < & String > ,
88
82
schema_version : SchemaVersion ,
89
83
log_source : & LogSource ,
90
- ) -> Result < ( Self :: Data , EventSchema , bool , Tags , Metadata ) , AnyError > ;
84
+ ) -> Result < ( Self :: Data , EventSchema , bool ) , AnyError > ;
91
85
92
86
fn decode ( data : Self :: Data , schema : Arc < Schema > ) -> Result < RecordBatch , AnyError > ;
93
87
@@ -99,26 +93,14 @@ pub trait EventFormat: Sized {
99
93
schema_version : SchemaVersion ,
100
94
log_source : & LogSource ,
101
95
) -> Result < ( RecordBatch , bool ) , AnyError > {
102
- let ( data, mut schema, is_first, tags , metadata ) = self . to_data (
96
+ let ( data, mut schema, is_first) = self . to_data (
103
97
storage_schema,
104
98
static_schema_flag,
105
99
time_partition,
106
100
schema_version,
107
101
log_source,
108
102
) ?;
109
103
110
- // DEFAULT_TAGS_KEY, DEFAULT_METADATA_KEY and DEFAULT_TIMESTAMP_KEY are reserved field names
111
- if get_field ( & schema, DEFAULT_TAGS_KEY ) . is_some ( ) {
112
- return Err ( anyhow ! ( "field {} is a reserved field" , DEFAULT_TAGS_KEY ) ) ;
113
- } ;
114
-
115
- if get_field ( & schema, DEFAULT_METADATA_KEY ) . is_some ( ) {
116
- return Err ( anyhow ! (
117
- "field {} is a reserved field" ,
118
- DEFAULT_METADATA_KEY
119
- ) ) ;
120
- } ;
121
-
122
104
if get_field ( & schema, DEFAULT_TIMESTAMP_KEY ) . is_some ( ) {
123
105
return Err ( anyhow ! (
124
106
"field {} is a reserved field" ,
@@ -136,16 +118,6 @@ pub trait EventFormat: Sized {
136
118
) ) ,
137
119
) ;
138
120
139
- // p_tags and p_metadata are added to the end of the schema
140
- let tags_index = schema. len ( ) ;
141
- let metadata_index = tags_index + 1 ;
142
- schema. push ( Arc :: new ( Field :: new ( DEFAULT_TAGS_KEY , DataType :: Utf8 , true ) ) ) ;
143
- schema. push ( Arc :: new ( Field :: new (
144
- DEFAULT_METADATA_KEY ,
145
- DataType :: Utf8 ,
146
- true ,
147
- ) ) ) ;
148
-
149
121
// prepare the record batch and new fields to be added
150
122
let mut new_schema = Arc :: new ( Schema :: new ( schema) ) ;
151
123
if !Self :: is_schema_matching ( new_schema. clone ( ) , storage_schema, static_schema_flag) {
@@ -154,16 +126,6 @@ pub trait EventFormat: Sized {
154
126
new_schema =
155
127
update_field_type_in_schema ( new_schema, None , time_partition, None , schema_version) ;
156
128
let rb = Self :: decode ( data, new_schema. clone ( ) ) ?;
157
- let tags_arr = StringArray :: from_iter_values ( std:: iter:: repeat ( & tags) . take ( rb. num_rows ( ) ) ) ;
158
- let metadata_arr =
159
- StringArray :: from_iter_values ( std:: iter:: repeat ( & metadata) . take ( rb. num_rows ( ) ) ) ;
160
- // modify the record batch to add fields to respective indexes
161
- let rb = utils:: arrow:: replace_columns (
162
- Arc :: clone ( & new_schema) ,
163
- & rb,
164
- & [ tags_index, metadata_index] ,
165
- & [ Arc :: new ( tags_arr) , Arc :: new ( metadata_arr) ] ,
166
- ) ;
167
129
168
130
Ok ( ( rb, is_first) )
169
131
}
0 commit comments