@@ -171,11 +171,18 @@ pub trait EventFormat: Sized {
171
171
) ) ,
172
172
) ;
173
173
174
- // prepare the record batch and new fields to be added
175
- let mut new_schema = Arc :: new ( Schema :: new ( schema) ) ;
176
- if !Self :: is_schema_matching ( new_schema. clone ( ) , storage_schema, static_schema_flag) {
174
+ if static_schema_flag
175
+ && schema. iter ( ) . any ( |field| {
176
+ storage_schema
177
+ . get ( field. name ( ) )
178
+ . is_none_or ( |storage_field| storage_field != field)
179
+ } )
180
+ {
177
181
return Err ( anyhow ! ( "Schema mismatch" ) ) ;
178
182
}
183
+
184
+ // prepare the record batch and new fields to be added
185
+ let mut new_schema = Arc :: new ( Schema :: new ( schema) ) ;
179
186
new_schema =
180
187
update_field_type_in_schema ( new_schema, None , time_partition, None , schema_version) ;
181
188
@@ -190,28 +197,6 @@ pub trait EventFormat: Sized {
190
197
Ok ( ( rb, is_first) )
191
198
}
192
199
193
- fn is_schema_matching (
194
- new_schema : Arc < Schema > ,
195
- storage_schema : & HashMap < String , Arc < Field > > ,
196
- static_schema_flag : bool ,
197
- ) -> bool {
198
- if !static_schema_flag {
199
- return true ;
200
- }
201
- for field in new_schema. fields ( ) {
202
- let Some ( storage_field) = storage_schema. get ( field. name ( ) ) else {
203
- return false ;
204
- } ;
205
- if field. name ( ) != storage_field. name ( ) {
206
- return false ;
207
- }
208
- if field. data_type ( ) != storage_field. data_type ( ) {
209
- return false ;
210
- }
211
- }
212
- true
213
- }
214
-
215
200
#[ allow( clippy:: too_many_arguments) ]
216
201
fn into_event (
217
202
self ,
0 commit comments