dramaticlly commented on code in PR #18342:
URL: https://github.com/apache/iceberg/pull/18342#discussion_r4160217975
##########
api/src/main/java/org/apache/iceberg/util/StructProjection.java:
##########
@@ -223,4 +223,19 @@ public <T> T get(int pos, Class<T> javaClass) {
public <T> void set(int pos, T value) {
throw new UnsupportedOperationException("Cannot set fields in a
TypeProjection");
}
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("StructProjection{");
+ List<Types.NestedField> fields = type.fields();
+ for (int i = 0; i < fields.size(); i += 1) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append(fields.get(i).name()).append("=").append(get(i, Object.class));
+ }
+ sb.append("}");
+ return sb.toString();
Review Comment:
I am wondering if helps to add a few tests in
https://github.com/apache/iceberg/blob/main/api/src/test/java/org/apache/iceberg/util/TestStructProjection.java
Given the current form, the structProjection toString only show the top
level field, which might not help much for the human-readable debug-ability. I
do feel that the toString is effectively a nested materialization for struct
projection, so probing is not free.
``` java
StructProjection.create(PROJECTED_STRUCT, PROJECTED_STRUCT).wrap(Row.of(1L,
Row.of("John", "Q", "Doe"))).toString()
//return "StructProjection{id=1,
person=org.apache.iceberg.TestHelpers$Row@447e510}"
// instead of desired
// "StructProjection{id=1, person=StructProjection{first=John, middle=Q,
last=Doe}}"
```
--
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]