@@ -118,34 +118,29 @@ impl CreateTableBuilder {
118118 }
119119
120120 // Validate partition spec references valid schema fields
121- if let Some ( ref partition_spec) = self . partition_spec {
122- if let Some ( spec) = partition_spec {
123- for field in spec. fields ( ) {
124- let source_id = field. source_id ( ) ;
125- if !schema. fields ( ) . iter ( ) . any ( |f| f. id == * source_id) {
126- return Err ( Error :: NotFound ( format ! (
121+ if let Some ( Some ( spec) ) = & self . partition_spec {
122+ for field in spec. fields ( ) {
123+ let source_id = field. source_id ( ) ;
124+ if !schema. fields ( ) . iter ( ) . any ( |f| f. id == * source_id) {
125+ return Err ( Error :: NotFound ( format ! (
127126 "Partition field '{}' references non-existent schema field ID {} in table '{}'" ,
128127 field. name( ) ,
129128 source_id,
130129 name
131130 ) ) ) ;
132- }
133131 }
134132 }
135133 }
136134
137135 // Validate sort order references valid schema fields
138- if let Some ( ref sort_order) = self . write_order {
139- if let Some ( order) = sort_order {
140- for field in & order. fields {
141- let source_id = field. source_id ;
142- if !schema. fields ( ) . iter ( ) . any ( |f| f. id == source_id) {
143- return Err ( Error :: NotFound ( format ! (
144- "Sort order field references non-existent schema field ID {} in table '{}'" ,
145- source_id,
146- name
147- ) ) ) ;
148- }
136+ if let Some ( Some ( order) ) = & self . write_order {
137+ for field in & order. fields {
138+ let source_id = field. source_id ;
139+ if !schema. fields ( ) . iter ( ) . any ( |f| f. id == source_id) {
140+ return Err ( Error :: NotFound ( format ! (
141+ "Sort order field references non-existent schema field ID {} in table '{}'" ,
142+ source_id, name
143+ ) ) ) ;
149144 }
150145 }
151146 }
0 commit comments