@@ -137,11 +137,18 @@ pub trait EventFormat: Sized {
137
137
) ) ,
138
138
) ;
139
139
140
- // prepare the record batch and new fields to be added
141
- let mut new_schema = Arc :: new ( Schema :: new ( schema) ) ;
142
- if !Self :: is_schema_matching ( new_schema. clone ( ) , storage_schema, static_schema_flag) {
140
+ if static_schema_flag
141
+ && schema. iter ( ) . any ( |field| {
142
+ storage_schema
143
+ . get ( field. name ( ) )
144
+ . is_none_or ( |storage_field| storage_field != field)
145
+ } )
146
+ {
143
147
return Err ( anyhow ! ( "Schema mismatch" ) ) ;
144
148
}
149
+
150
+ // prepare the record batch and new fields to be added
151
+ let mut new_schema = Arc :: new ( Schema :: new ( schema) ) ;
145
152
new_schema =
146
153
update_field_type_in_schema ( new_schema, None , time_partition, None , schema_version) ;
147
154
@@ -156,28 +163,6 @@ pub trait EventFormat: Sized {
156
163
Ok ( ( rb, is_first) )
157
164
}
158
165
159
- fn is_schema_matching (
160
- new_schema : Arc < Schema > ,
161
- storage_schema : & HashMap < String , Arc < Field > > ,
162
- static_schema_flag : bool ,
163
- ) -> bool {
164
- if !static_schema_flag {
165
- return true ;
166
- }
167
- for field in new_schema. fields ( ) {
168
- let Some ( storage_field) = storage_schema. get ( field. name ( ) ) else {
169
- return false ;
170
- } ;
171
- if field. name ( ) != storage_field. name ( ) {
172
- return false ;
173
- }
174
- if field. data_type ( ) != storage_field. data_type ( ) {
175
- return false ;
176
- }
177
- }
178
- true
179
- }
180
-
181
166
#[ allow( clippy:: too_many_arguments) ]
182
167
fn into_event (
183
168
self ,
0 commit comments