File tree 1 file changed +23
-7
lines changed
1 file changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -158,19 +158,35 @@ pub trait EventFormat: Sized {
158
158
) ) ,
159
159
) ;
160
160
161
- if static_schema_flag
162
- && schema. iter ( ) . any ( |field| {
163
- storage_schema
164
- . get ( field. name ( ) )
165
- . is_none_or ( |storage_field| storage_field != field)
166
- } )
167
- {
161
+ if !Self :: is_schema_matching ( & schema, storage_schema, static_schema_flag) {
168
162
return Err ( anyhow ! ( "Schema mismatch" ) ) ;
169
163
}
170
164
171
165
Ok ( schema)
172
166
}
173
167
168
+ fn is_schema_matching (
169
+ schema : & EventSchema ,
170
+ storage_schema : & HashMap < String , Arc < Field > > ,
171
+ static_schema_flag : bool ,
172
+ ) -> bool {
173
+ if !static_schema_flag {
174
+ return true ;
175
+ }
176
+ for field in schema. iter ( ) {
177
+ let Some ( storage_field) = storage_schema. get ( field. name ( ) ) else {
178
+ return false ;
179
+ } ;
180
+ if field. name ( ) != storage_field. name ( ) {
181
+ return false ;
182
+ }
183
+ if field. data_type ( ) != storage_field. data_type ( ) {
184
+ return false ;
185
+ }
186
+ }
187
+ true
188
+ }
189
+
174
190
fn into_recordbatch (
175
191
p_timestamp : DateTime < Utc > ,
176
192
data : & [ Self :: Data ] ,
You can’t perform that action at this time.
0 commit comments