jackye1995 commented on a change in pull request #2936:
URL: https://github.com/apache/iceberg/pull/2936#discussion_r682971431
##########
File path: core/src/main/java/org/apache/iceberg/Partitioning.java
##########
@@ -177,4 +184,35 @@ public Void alwaysNull(int fieldId, String sourceName, int
sourceId) {
return null;
}
}
+
+ /**
+ * Builds a common partition type for all specs in a table.
+ *
+ * @param table a table with one or many specs
+ * @return the constructed common partition type
+ */
+ public static StructType partitionType(Table table) {
+ Map<Integer, NestedField> commonFields = Maps.newHashMap();
+
+ for (PartitionSpec spec : table.specs().values()) {
+ List<NestedField> fields = spec.partitionType().fields();
+
+ for (NestedField field : fields) {
+ int fieldId = field.fieldId();
+ NestedField existingField = commonFields.get(fieldId);
+
+ // partition fields may conflict in v1 tables
+ ValidationException.check(existingField == null ||
existingField.equals(field),
+ "Specs contain conflicting partition fields with ID %d",
Review comment:
+1, can just use `"... with %s", field`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]