kennknowles commented on code in PR #32939:
URL: https://github.com/apache/beam/pull/32939#discussion_r1884208676
##########
sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/RecordWriterManager.java:
##########
@@ -185,8 +204,65 @@ private RecordWriter createWriter(PartitionKey
partitionKey) {
e);
}
}
+
+ /**
+ * Resolves an input {@link Record}'s partition values and returns another
{@link Record} that
+ * can be applied to the destination's {@link PartitionSpec}.
+ */
+ private Record getPartitionableRecord(Record record) {
+ if (spec.isUnpartitioned()) {
+ return record;
+ }
+ Record output = GenericRecord.create(schema);
+ for (PartitionField partitionField : spec.fields()) {
+ Transform<?, ?> transform = partitionField.transform();
+ Types.NestedField field = schema.findField(partitionField.sourceId());
+ String name = field.name();
+ Object value = record.getField(name);
+ @Nullable Literal<Object> literal =
Literal.of(value.toString()).to(field.type());
+ if (literal == null || transform.isVoid() || transform.isIdentity()) {
+ output.setField(name, value);
+ } else {
+ output.setField(name, literal.value());
+ }
+ }
+ return output;
+ }
}
+ /**
+ * Returns an equivalent partition path that is made up of partition data.
Needed to reconstruct a
+ * {@link DataFile}.
+ */
+ @VisibleForTesting
+ static String getPartitionDataPath(
+ String partitionPath, Map<String, PartitionField> partitionFieldMap) {
+ if (Strings.isNullOrEmpty(partitionPath) || partitionFieldMap.isEmpty()) {
Review Comment:
null would be a type error here (since no `@Nullable`) so we should give an
error message
--
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]