amogh-jahagirdar commented on code in PR #18342:
URL: https://github.com/apache/iceberg/pull/18342#discussion_r4159475617
##########
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:
>it might have side effect of invoking
javaClass.cast(nestedProjections[pos].wrap(nestedStruct)),
This is a great callout, I missed this originally but any reason we can't
just read from the actual struct? Otherwise logging one of these may lead to
really unexpected results after the logging as a result of the side effect.
##########
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:
>it might have side effect of invoking
javaClass.cast(nestedProjections[pos].wrap(nestedStruct)),
This is a great callout, I missed this originally but any reason we can't
just read from the actual struct? Otherwise logging one of these may lead to
really unexpected results after the logging as a result of the side effect.
--
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]