rdblue commented on code in PR #17960:
URL: https://github.com/apache/iceberg/pull/17960#discussion_r4138241559


##########
core/src/main/java/org/apache/iceberg/MetricsConfig.java:
##########
@@ -338,6 +346,24 @@ private static Map<String, MetricsMode> 
configuredColumnModes(Map<String, String
     return builder.build();
   }
 
+  private static Map<String, MetricsMode> partitionColumnModes(PartitionSpec 
spec, Schema schema) {
+    if (spec == null || schema == null) {
+      return ImmutableMap.of();
+    }
+
+    ImmutableMap.Builder<String, MetricsMode> builder = ImmutableMap.builder();
+    for (PartitionField field : spec.fields()) {
+      if (field.transform().preservesOrder()) {
+        String name = schema.findColumnName(field.sourceId());
+        Preconditions.checkArgument(
+            name != null, "Cannot find source column for partition field: %s", 
field.name());
+        builder.put(name, MetricsModes.Full.get());

Review Comment:
   I think there are only two cases we need to worry about with variable-length 
data:
   - `identity` always requires full because values cannot be truncated
   - `truncate[W]` could use `truncate(>W)` because the lower bound is always a 
simple truncation
   
   Truncate is a little tricky because truncation for upper bounds can be a 
shorter string, or one that is the right length but doesn't match the lower 
bound's prefix. We should make sure we only use the lower bound to produce 
partition values.
   
   Always using `Full` is the safest call, but I think this could also allow 
stats truncation. Probably good to add a comment explaining the use of full for 
now.



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