anoopj commented on code in PR #18342:
URL: https://github.com/apache/iceberg/pull/18342#discussion_r4161352517
##########
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 think both are good points. I initially hesitated to add tests because
currently we don't have many `toString` tests in the project.
I made toString descend into nested projections. To avoid the wrap() side
effect we discussed above, the nested descent uses `copyFor`, which wraps a
fresh projection instead of mutating the shared nested one. This is OK, because
we don't expect `toString()` to be used in the inner loop.
--
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]