File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -269,6 +269,16 @@ impl Schema {
269269 }
270270 }
271271
272+ /// Create a new schema builder from a schema.
273+ pub fn into_builder ( self ) -> SchemaBuilder {
274+ SchemaBuilder {
275+ schema_id : self . schema_id ,
276+ fields : self . r#struct . fields ( ) . to_vec ( ) ,
277+ alias_to_id : self . alias_to_id ,
278+ identifier_field_ids : self . identifier_field_ids ,
279+ }
280+ }
281+
272282 /// Get field by field id.
273283 pub fn field_by_id ( & self , field_id : i32 ) -> Option < & NestedFieldRef > {
274284 self . id_to_field . get ( & field_id)
@@ -1304,6 +1314,15 @@ table {
13041314 . contains( "Invalid schema: multiple fields for name baz" ) ) ;
13051315 }
13061316
1317+ #[ test]
1318+ fn test_schema_into_builder ( ) {
1319+ let original_schema = table_schema_nested ( ) ;
1320+ let builder = original_schema. clone ( ) . into_builder ( ) ;
1321+ let schema = builder. build ( ) . unwrap ( ) ;
1322+
1323+ assert_eq ! ( original_schema, schema) ;
1324+ }
1325+
13071326 #[ test]
13081327 fn test_schema_index_by_name ( ) {
13091328 let expected_name_to_id = HashMap :: from (
You can’t perform that action at this time.
0 commit comments