@@ -139,6 +139,22 @@ impl AvroField {
139139pub  fn  name ( & self )  -> & str  { 
140140        & self . name 
141141    } 
142+ 
143+     /// Performs schema resolution between a writer and reader schema. 
144+ /// 
145+ /// This is the primary entry point for handling schema evolution. It produces an 
146+ /// `AvroField` that contains all the necessary information to read data written 
147+ /// with the `writer` schema as if it were written with the `reader` schema. 
148+ pub  fn  resolve_from_writer_and_reader < ' a > ( 
149+         writer :  & ' a  Schema < ' a > , 
150+         reader :  & ' a  Schema < ' a > , 
151+         use_utf8view :  bool , 
152+         strict_mode :  bool , 
153+     )  -> Result < Self ,  ArrowError >  { 
154+         Err ( ArrowError :: NotYetImplemented ( 
155+             "Resolving schema from a writer and reader schema is not yet implemented" . to_string ( ) , 
156+         ) ) 
157+     } 
142158} 
143159
144160impl < ' a >  TryFrom < & Schema < ' a > >  for  AvroField  { 
@@ -164,21 +180,33 @@ impl<'a> TryFrom<&Schema<'a>> for AvroField {
164180/// Builder for an [`AvroField`] 
165181#[ derive( Debug ) ]  
166182pub  struct  AvroFieldBuilder < ' a >  { 
167-     schema :  & ' a  Schema < ' a > , 
183+     writer_schema :  & ' a  Schema < ' a > , 
184+     reader_schema :  Option < & ' a  Schema < ' a > > , 
168185    use_utf8view :  bool , 
169186    strict_mode :  bool , 
170187} 
171188
172189impl < ' a >  AvroFieldBuilder < ' a >  { 
173-     /// Creates a new [`AvroFieldBuilder`] 
174- pub  fn  new ( schema :  & ' a  Schema < ' a > )  -> Self  { 
190+     /// Creates a new [`AvroFieldBuilder`] for a given writer schema.  
191+ pub  fn  new ( writer_schema :  & ' a  Schema < ' a > )  -> Self  { 
175192        Self  { 
176-             schema, 
193+             writer_schema, 
194+             reader_schema :  None , 
177195            use_utf8view :  false , 
178196            strict_mode :  false , 
179197        } 
180198    } 
181199
200+     /// Sets the reader schema for schema resolution. 
201+ /// 
202+ /// If a reader schema is provided, the builder will produce a resolved `AvroField` 
203+ /// that can handle differences between the writer's and reader's schemas. 
204+ #[ inline]  
205+     pub  fn  with_reader_schema ( mut  self ,  reader_schema :  & ' a  Schema < ' a > )  -> Self  { 
206+         self . reader_schema  = Some ( reader_schema) ; 
207+         self 
208+     } 
209+ 
182210    /// Enable or disable Utf8View support 
183211pub  fn  with_utf8view ( mut  self ,  use_utf8view :  bool )  -> Self  { 
184212        self . use_utf8view  = use_utf8view; 
@@ -193,11 +221,11 @@ impl<'a> AvroFieldBuilder<'a> {
193221
194222    /// Build an [`AvroField`] from the builder 
195223pub  fn  build ( self )  -> Result < AvroField ,  ArrowError >  { 
196-         match  self . schema  { 
224+         match  self . writer_schema  { 
197225            Schema :: Complex ( ComplexType :: Record ( r) )  => { 
198226                let  mut  resolver = Resolver :: default ( ) ; 
199227                let  data_type = make_data_type ( 
200-                     self . schema , 
228+                     self . writer_schema , 
201229                    None , 
202230                    & mut  resolver, 
203231                    self . use_utf8view , 
@@ -210,7 +238,7 @@ impl<'a> AvroFieldBuilder<'a> {
210238            } 
211239            _ => Err ( ArrowError :: ParseError ( format ! ( 
212240                "Expected a Record schema to build an AvroField, but got {:?}" , 
213-                 self . schema 
241+                 self . writer_schema 
214242            ) ) ) , 
215243        } 
216244    } 
0 commit comments