@@ -240,21 +240,30 @@ public static ResolvedPartitionSpec toResolvedPartitionSpec(PbPartitionSpec pbPa
240
240
public static ResolvedPartitionSpec toResolvedPartitionSpec (
241
241
PbPartitionSpec pbPartitionSpec , List <String > orderedPartitionKeys ) {
242
242
243
- Map <String , String > keyValueMap = new HashMap <>();
244
- for (PbKeyValue pbKeyValue : pbPartitionSpec .getPartitionKeyValuesList ()) {
245
- keyValueMap .put (pbKeyValue .getKey (), pbKeyValue .getValue ());
243
+ List <PbKeyValue > partitionKeyValuesList = pbPartitionSpec .getPartitionKeyValuesList ();
244
+ if (partitionKeyValuesList .size () != orderedPartitionKeys .size ()) {
245
+ return toResolvedPartitionSpec (pbPartitionSpec );
246
+ }
247
+
248
+ Map <String , String > pbkeyValueMap = new HashMap <>();
249
+ for (PbKeyValue pbKeyValue : partitionKeyValuesList ) {
250
+ if (!orderedPartitionKeys .contains (pbKeyValue .getKey ())) {
251
+ return toResolvedPartitionSpec (pbPartitionSpec );
252
+ }
253
+ pbkeyValueMap .put (pbKeyValue .getKey (), pbKeyValue .getValue ());
246
254
}
247
- List <String > presentKeys = new ArrayList <>();
248
- List <String > orderedValues = new ArrayList <>();
255
+
256
+ List <String > partitionKeys = new ArrayList <>();
257
+ List <String > orderedPartitionValues = new ArrayList <>();
249
258
250
259
for (String orderedKey : orderedPartitionKeys ) {
251
- String value = keyValueMap .get (orderedKey );
260
+ String value = pbkeyValueMap .get (orderedKey );
252
261
if (value != null ) {
253
- presentKeys .add (orderedKey );
254
- orderedValues .add (value );
262
+ partitionKeys .add (orderedKey );
263
+ orderedPartitionValues .add (value );
255
264
}
256
265
}
257
266
258
- return new ResolvedPartitionSpec (presentKeys , orderedValues );
267
+ return new ResolvedPartitionSpec (partitionKeys , orderedPartitionValues );
259
268
}
260
269
}
0 commit comments