Commit e08c0e5 1 parent f78c59b commit e08c0e5 Copy full SHA for e08c0e5
File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -106,8 +106,6 @@ impl SchemaBuilder {
106
106
107
107
/// Builds the schema.
108
108
pub fn build ( self ) -> Result < Schema > {
109
- let highest_field_id = self . fields . iter ( ) . map ( |f| f. id ) . max ( ) . unwrap_or ( 0 ) ;
110
-
111
109
let field_id_to_accessor = self . build_accessors ( ) ;
112
110
113
111
let r#struct = StructType :: new ( self . fields ) ;
@@ -130,12 +128,13 @@ impl SchemaBuilder {
130
128
. map ( |( k, v) | ( k. to_lowercase ( ) , * v) )
131
129
. collect ( ) ;
132
130
131
+ let highest_field_id = id_to_field. keys ( ) . max ( ) . cloned ( ) . unwrap_or ( 0 ) ;
132
+
133
133
Ok ( Schema {
134
134
r#struct,
135
135
schema_id : self . schema_id ,
136
136
highest_field_id,
137
137
identifier_field_ids : self . identifier_field_ids ,
138
-
139
138
alias_to_id : self . alias_to_id ,
140
139
id_to_field,
141
140
@@ -2229,4 +2228,13 @@ table {
2229
2228
assert ! ( result. is_ok( ) ) ;
2230
2229
assert_eq ! ( result. unwrap( ) , Type :: Struct ( schema. as_struct( ) . clone( ) ) ) ;
2231
2230
}
2231
+
2232
+ #[ test]
2233
+ fn test_highest_field_id ( ) {
2234
+ let schema = table_schema_nested ( ) ;
2235
+ assert_eq ! ( 17 , schema. highest_field_id( ) ) ;
2236
+
2237
+ let schema = table_schema_simple ( ) . 0 ;
2238
+ assert_eq ! ( 3 , schema. highest_field_id( ) ) ;
2239
+ }
2232
2240
}
You can’t perform that action at this time.
0 commit comments