RussellSpitzer commented on code in PR #13137:
URL: https://github.com/apache/iceberg/pull/13137#discussion_r2286068932


##########
api/src/main/java/org/apache/iceberg/expressions/ExpressionUtil.java:
##########
@@ -646,6 +655,95 @@ private static String sanitizeSimpleString(CharSequence 
value) {
     return String.format(Locale.ROOT, "(hash-%08x)", HASH_FUNC.apply(value));
   }
 
+  private static String sanitizeVariant(Variant value, long now, int today) {
+    return sanitizeVariant(value.value(), now, today);
+  }
+
+  private static String sanitizeVariant(VariantValue value, long now, int 
today) {
+    if (value instanceof VariantObject) {
+      return sanitizeVariantObject(value.asObject(), now, today);
+    } else if (value instanceof VariantPrimitive) {
+      return sanitizeVariantValue(value.asPrimitive(), value.type(), now, 
today);
+    } else {
+      return sanitizeVariantArray(value.asArray(), now, today);
+    }
+  }
+
+  private static String sanitizeVariantObject(VariantObject value, long now, 
int today) {

Review Comment:
   Personal opinion: I generally dislike the stateful string builder pattern. 
This is just a suggestion but if you like
   
   ```java
   private static String sanitizeVariantObject(VariantObject value, long now, 
int today) {
     return value.fieldNames().stream()
       .map(field -> {
         VariantValue fieldValue = value.get(field);
         PhysicalType fieldType = fieldValue.type();
         return String.format(Locale.ROOT, "(hash-%s): %s", field, 
           sanitizeVariantValue(fieldValue, fieldType, now, today));
       })
       .collect(Collectors.joining(", ", "{", "}"));
   }
   ```



-- 
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]

Reply via email to