@@ -134,7 +134,7 @@ pub struct UnboundPartitionField {
134134 /// A partition field id that is used to identify a partition field and is unique within a partition spec.
135135 /// In v2 table metadata, it is unique across all partition specs.
136136 #[ builder( default , setter( strip_option) ) ]
137- pub partition_id : Option < i32 > ,
137+ pub field_id : Option < i32 > ,
138138 /// A partition name.
139139 pub name : String ,
140140 /// A transform that is applied to the source column to produce a partition value.
@@ -177,7 +177,7 @@ impl From<PartitionField> for UnboundPartitionField {
177177 fn from ( field : PartitionField ) -> Self {
178178 UnboundPartitionField {
179179 source_id : field. source_id ,
180- partition_id : Some ( field. field_id ) ,
180+ field_id : Some ( field. field_id ) ,
181181 name : field. name ,
182182 transform : field. transform ,
183183 }
@@ -224,7 +224,7 @@ impl UnboundPartitionSpecBuilder {
224224 ) -> Result < Self > {
225225 let field = UnboundPartitionField {
226226 source_id,
227- partition_id : None ,
227+ field_id : None ,
228228 name : target_name. to_string ( ) ,
229229 transform : transformation,
230230 } ;
@@ -246,8 +246,8 @@ impl UnboundPartitionSpecBuilder {
246246 fn add_partition_field_internal ( mut self , field : UnboundPartitionField ) -> Result < Self > {
247247 self . check_name_set_and_unique ( & field. name ) ?;
248248 self . check_for_redundant_partitions ( field. source_id , & field. transform ) ?;
249- if let Some ( partition_id ) = field. partition_id {
250- self . check_partition_id_unique ( partition_id ) ?;
249+ if let Some ( partition_field_id ) = field. field_id {
250+ self . check_partition_id_unique ( partition_field_id ) ?;
251251 }
252252 self . fields . push ( field) ;
253253 Ok ( self )
@@ -331,7 +331,7 @@ impl<'a> PartitionSpecBuilder<'a> {
331331 . id ;
332332 let field = UnboundPartitionField {
333333 source_id,
334- partition_id : None ,
334+ field_id : None ,
335335 name : target_name. into ( ) ,
336336 transform,
337337 } ;
@@ -341,15 +341,15 @@ impl<'a> PartitionSpecBuilder<'a> {
341341
342342 /// Add a new partition field to the partition spec.
343343 ///
344- /// If `partition_id` is set, it is used as the field id.
344+ /// If partition field id is set, it is used as the field id.
345345 /// Otherwise, a new `field_id` is assigned.
346346 pub fn add_unbound_field ( mut self , field : UnboundPartitionField ) -> Result < Self > {
347347 self . check_name_set_and_unique ( & field. name ) ?;
348348 self . check_for_redundant_partitions ( field. source_id , & field. transform ) ?;
349349 Self :: check_name_does_not_collide_with_schema ( & field, self . schema ) ?;
350350 Self :: check_transform_compatibility ( & field, self . schema ) ?;
351- if let Some ( partition_id ) = field. partition_id {
352- self . check_partition_id_unique ( partition_id ) ?;
351+ if let Some ( partition_field_id ) = field. field_id {
352+ self . check_partition_id_unique ( partition_field_id ) ?;
353353 }
354354
355355 // Non-fallible from here
@@ -387,7 +387,7 @@ impl<'a> PartitionSpecBuilder<'a> {
387387 // we skip it.
388388 let assigned_ids = fields
389389 . iter ( )
390- . filter_map ( |f| f. partition_id )
390+ . filter_map ( |f| f. field_id )
391391 . collect :: < std:: collections:: HashSet < _ > > ( ) ;
392392
393393 fn _check_add_1 ( prev : i32 ) -> Result < i32 > {
@@ -401,9 +401,9 @@ impl<'a> PartitionSpecBuilder<'a> {
401401
402402 let mut bound_fields = Vec :: with_capacity ( fields. len ( ) ) ;
403403 for field in fields. into_iter ( ) {
404- let partition_id = if let Some ( partition_id ) = field. partition_id {
405- last_assigned_field_id = std:: cmp:: max ( last_assigned_field_id, partition_id ) ;
406- partition_id
404+ let partition_field_id = if let Some ( partition_field_id ) = field. field_id {
405+ last_assigned_field_id = std:: cmp:: max ( last_assigned_field_id, partition_field_id ) ;
406+ partition_field_id
407407 } else {
408408 last_assigned_field_id = _check_add_1 ( last_assigned_field_id) ?;
409409 while assigned_ids. contains ( & last_assigned_field_id) {
@@ -414,7 +414,7 @@ impl<'a> PartitionSpecBuilder<'a> {
414414
415415 bound_fields. push ( PartitionField {
416416 source_id : field. source_id ,
417- field_id : partition_id ,
417+ field_id : partition_field_id ,
418418 name : field. name ,
419419 transform : field. transform ,
420420 } )
@@ -544,11 +544,7 @@ trait CorePartitionSpecValidator {
544544
545545 /// Check field / partition_id unique within the partition spec if set
546546 fn check_partition_id_unique ( & self , field_id : i32 ) -> Result < ( ) > {
547- if self
548- . fields ( )
549- . iter ( )
550- . any ( |f| f. partition_id == Some ( field_id) )
551- {
547+ if self . fields ( ) . iter ( ) . any ( |f| f. field_id == Some ( field_id) ) {
552548 return Err ( Error :: new (
553549 ErrorKind :: DataInvalid ,
554550 format ! (
@@ -698,17 +694,17 @@ mod tests {
698694 "spec-id": 1,
699695 "fields": [ {
700696 "source-id": 4,
701- "partition -id": 1000,
697+ "field -id": 1000,
702698 "name": "ts_day",
703699 "transform": "day"
704700 }, {
705701 "source-id": 1,
706- "partition -id": 1001,
702+ "field -id": 1001,
707703 "name": "id_bucket",
708704 "transform": "bucket[16]"
709705 }, {
710706 "source-id": 2,
711- "partition -id": 1002,
707+ "field -id": 1002,
712708 "name": "id_truncate",
713709 "transform": "truncate[4]"
714710 } ]
@@ -719,17 +715,17 @@ mod tests {
719715 assert_eq ! ( Some ( 1 ) , partition_spec. spec_id) ;
720716
721717 assert_eq ! ( 4 , partition_spec. fields[ 0 ] . source_id) ;
722- assert_eq ! ( Some ( 1000 ) , partition_spec. fields[ 0 ] . partition_id ) ;
718+ assert_eq ! ( Some ( 1000 ) , partition_spec. fields[ 0 ] . field_id ) ;
723719 assert_eq ! ( "ts_day" , partition_spec. fields[ 0 ] . name) ;
724720 assert_eq ! ( Transform :: Day , partition_spec. fields[ 0 ] . transform) ;
725721
726722 assert_eq ! ( 1 , partition_spec. fields[ 1 ] . source_id) ;
727- assert_eq ! ( Some ( 1001 ) , partition_spec. fields[ 1 ] . partition_id ) ;
723+ assert_eq ! ( Some ( 1001 ) , partition_spec. fields[ 1 ] . field_id ) ;
728724 assert_eq ! ( "id_bucket" , partition_spec. fields[ 1 ] . name) ;
729725 assert_eq ! ( Transform :: Bucket ( 16 ) , partition_spec. fields[ 1 ] . transform) ;
730726
731727 assert_eq ! ( 2 , partition_spec. fields[ 2 ] . source_id) ;
732- assert_eq ! ( Some ( 1002 ) , partition_spec. fields[ 2 ] . partition_id ) ;
728+ assert_eq ! ( Some ( 1002 ) , partition_spec. fields[ 2 ] . field_id ) ;
733729 assert_eq ! ( "id_truncate" , partition_spec. fields[ 2 ] . name) ;
734730 assert_eq ! ( Transform :: Truncate ( 4 ) , partition_spec. fields[ 2 ] . transform) ;
735731
@@ -746,7 +742,7 @@ mod tests {
746742 assert_eq ! ( None , partition_spec. spec_id) ;
747743
748744 assert_eq ! ( 4 , partition_spec. fields[ 0 ] . source_id) ;
749- assert_eq ! ( None , partition_spec. fields[ 0 ] . partition_id ) ;
745+ assert_eq ! ( None , partition_spec. fields[ 0 ] . field_id ) ;
750746 assert_eq ! ( "ts_day" , partition_spec. fields[ 0 ] . name) ;
751747 assert_eq ! ( Transform :: Day , partition_spec. fields[ 0 ] . transform) ;
752748 }
@@ -963,14 +959,14 @@ mod tests {
963959 PartitionSpec :: builder ( & schema)
964960 . add_unbound_field ( UnboundPartitionField {
965961 source_id : 1 ,
966- partition_id : Some ( 1000 ) ,
962+ field_id : Some ( 1000 ) ,
967963 name : "id" . to_string ( ) ,
968964 transform : Transform :: Identity ,
969965 } )
970966 . unwrap ( )
971967 . add_unbound_field ( UnboundPartitionField {
972968 source_id : 2 ,
973- partition_id : Some ( 1000 ) ,
969+ field_id : Some ( 1000 ) ,
974970 name : "id_bucket" . to_string ( ) ,
975971 transform : Transform :: Bucket ( 16 ) ,
976972 } )
@@ -1004,22 +1000,22 @@ mod tests {
10041000 source_id : 1 ,
10051001 name : "id" . to_string ( ) ,
10061002 transform : Transform :: Identity ,
1007- partition_id : Some ( 1012 ) ,
1003+ field_id : Some ( 1012 ) ,
10081004 } )
10091005 . unwrap ( )
10101006 . add_unbound_field ( UnboundPartitionField {
10111007 source_id : 2 ,
10121008 name : "name_void" . to_string ( ) ,
10131009 transform : Transform :: Void ,
1014- partition_id : None ,
1010+ field_id : None ,
10151011 } )
10161012 . unwrap ( )
10171013 // Should keep its ID even if its lower
10181014 . add_unbound_field ( UnboundPartitionField {
10191015 source_id : 3 ,
10201016 name : "year" . to_string ( ) ,
10211017 transform : Transform :: Year ,
1022- partition_id : Some ( 1 ) ,
1018+ field_id : Some ( 1 ) ,
10231019 } )
10241020 . unwrap ( )
10251021 . build ( )
@@ -1090,7 +1086,7 @@ mod tests {
10901086 . with_spec_id ( 1 )
10911087 . add_unbound_field ( UnboundPartitionField {
10921088 source_id : 1 ,
1093- partition_id : None ,
1089+ field_id : None ,
10941090 name : "id" . to_string ( ) ,
10951091 transform : Transform :: Bucket ( 16 ) ,
10961092 } )
@@ -1123,7 +1119,7 @@ mod tests {
11231119 . with_spec_id ( 1 )
11241120 . add_unbound_field ( UnboundPartitionField {
11251121 source_id : 1 ,
1126- partition_id : None ,
1122+ field_id : None ,
11271123 name : "id" . to_string ( ) ,
11281124 transform : Transform :: Identity ,
11291125 } )
@@ -1136,7 +1132,7 @@ mod tests {
11361132 . with_spec_id ( 1 )
11371133 . add_unbound_field ( UnboundPartitionField {
11381134 source_id : 2 ,
1139- partition_id : None ,
1135+ field_id : None ,
11401136 name : "id" . to_string ( ) ,
11411137 transform : Transform :: Identity ,
11421138 } )
@@ -1171,13 +1167,13 @@ mod tests {
11711167 . add_unbound_fields ( vec ! [
11721168 UnboundPartitionField {
11731169 source_id: 1 ,
1174- partition_id : None ,
1170+ field_id : None ,
11751171 name: "id_bucket" . to_string( ) ,
11761172 transform: Transform :: Bucket ( 16 ) ,
11771173 } ,
11781174 UnboundPartitionField {
11791175 source_id: 2 ,
1180- partition_id : None ,
1176+ field_id : None ,
11811177 name: "name" . to_string( ) ,
11821178 transform: Transform :: Identity ,
11831179 } ,
@@ -1192,13 +1188,13 @@ mod tests {
11921188 . add_unbound_fields ( vec ! [
11931189 UnboundPartitionField {
11941190 source_id: 1 ,
1195- partition_id : None ,
1191+ field_id : None ,
11961192 name: "id_bucket" . to_string( ) ,
11971193 transform: Transform :: Bucket ( 16 ) ,
11981194 } ,
11991195 UnboundPartitionField {
12001196 source_id: 4 ,
1201- partition_id : None ,
1197+ field_id : None ,
12021198 name: "name" . to_string( ) ,
12031199 transform: Transform :: Identity ,
12041200 } ,
@@ -1237,7 +1233,7 @@ mod tests {
12371233 . with_spec_id ( 1 )
12381234 . add_unbound_field ( UnboundPartitionField {
12391235 source_id : 1 ,
1240- partition_id : None ,
1236+ field_id : None ,
12411237 name : "id_year" . to_string ( ) ,
12421238 transform : Transform :: Year ,
12431239 } )
@@ -1250,7 +1246,7 @@ mod tests {
12501246 . with_spec_id ( 1 )
12511247 . add_partition_fields ( vec ! [ UnboundPartitionField {
12521248 source_id: 1 ,
1253- partition_id : None ,
1249+ field_id : None ,
12541250 name: "id_bucket[16]" . to_string( ) ,
12551251 transform: Transform :: Bucket ( 16 ) ,
12561252 } ] )
@@ -1261,7 +1257,7 @@ mod tests {
12611257 spec_id: Some ( 1 ) ,
12621258 fields: vec![ UnboundPartitionField {
12631259 source_id: 1 ,
1264- partition_id : None ,
1260+ field_id : None ,
12651261 name: "id_bucket[16]" . to_string( ) ,
12661262 transform: Transform :: Bucket ( 16 ) ,
12671263 } ]
0 commit comments