File tree Expand file tree Collapse file tree 1 file changed +23
-7
lines changed Expand file tree Collapse file tree 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 {
158158 ) ) ,
159159 ) ;
160160
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) {
168162 return Err ( anyhow ! ( "Schema mismatch" ) ) ;
169163 }
170164
171165 Ok ( schema)
172166 }
173167
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+
174190 fn into_recordbatch (
175191 p_timestamp : DateTime < Utc > ,
176192 data : & [ Self :: Data ] ,
You can’t perform that action at this time.
0 commit comments