Copilot commented on code in PR #15175:
URL: https://github.com/apache/iceberg/pull/15175#discussion_r2739597723
##########
api/src/main/java/org/apache/iceberg/util/StructProjection.java:
##########
@@ -179,10 +180,19 @@ public int projectedFields() {
}
public StructProjection wrap(StructLike newStruct) {
+ return wrap(newStruct, null);
+ }
+
+ public StructProjection wrap(StructLike newStruct, String description) {
this.struct = newStruct;
+ this.description = description;
return this;
}
+ public String getDescription() {
+ return description;
+ }
+
public StructProjection copyFor(StructLike newStruct) {
return new StructProjection(type, positionMap,
nestedProjections).wrap(newStruct);
Review Comment:
The `copyFor` method does not preserve the `description` field from the
original `StructProjection`. This could lead to loss of partition description
information when a copy is created. The description should be copied to the new
instance.
```suggestion
return new StructProjection(type, positionMap,
nestedProjections).wrap(newStruct, description);
```
##########
spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/actions/RewritePositionDeleteFilesSparkAction.java:
##########
@@ -377,4 +378,11 @@ private String jobDesc(
table.name());
}
}
+
+ private String getPartitionDescription(StructLike partition) {
+ Preconditions.checkArgument(
+ partition instanceof StructProjection,
+ "Partition must be a StructProjection to retrieve description");
+ return ((StructProjection) partition).getDescription();
Review Comment:
The method does not handle the case where `getDescription()` returns null.
If the `StructProjection` was not wrapped with a description, this will return
null and could result in 'null' being displayed in the job description.
Consider providing a fallback to `partition.toString()` when description is
null.
```suggestion
String description = ((StructProjection) partition).getDescription();
return description != null ? description : partition.toString();
```
--
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]