rdblue commented on code in PR #17960:
URL: https://github.com/apache/iceberg/pull/17960#discussion_r4138142652
##########
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());
+ }
+ }
+
+ return builder.buildKeepingLast();
Review Comment:
Would be nice to comment that multiple fields can have the same source ID,
so `buildKeepingLast` is needed.
##########
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());
+ }
+ }
+
+ return builder.buildKeepingLast();
Review Comment:
Would be nice to comment that multiple fields can have the same source ID,
so `buildKeepingLast` is needed. This is also a good test case!
--
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]