aokolnychyi commented on a change in pull request #2240:
URL: https://github.com/apache/iceberg/pull/2240#discussion_r707846978



##########
File path: core/src/main/java/org/apache/iceberg/avro/Avro.java
##########
@@ -256,7 +256,7 @@ public DataWriteBuilder forTable(Table table) {
       schema(table.schema());
       withSpec(table.spec());
       setAll(table.properties());
-      metricsConfig(MetricsConfig.fromProperties(table.properties()));
+      metricsConfig(MetricsConfig.forTable(table));

Review comment:
       Do we need to do the same in Avro `WriteBuilder` too?
   I don't think we use that method right now but should make sense for 
consistency.
   We already handle that for Parquet.

##########
File path: core/src/main/java/org/apache/iceberg/util/SortOrderUtil.java
##########
@@ -64,4 +68,16 @@ static SortOrder buildSortOrder(Schema schema, PartitionSpec 
spec, SortOrder sor
 
     return builder.build();
   }
+
+  public static Set<String> sortedColumns(SortOrder sortOrder) {
+    if (sortOrder == null) {
+      return Collections.emptySet();
+    } else {
+      return sortOrder.fields().stream()
+          .map(SortField::sourceId)
+          .map(sid -> sortOrder.schema().findColumnName(sid))

Review comment:
       The implementation here looks correct to me now.

##########
File path: core/src/main/java/org/apache/iceberg/MetricsConfig.java
##########
@@ -76,7 +78,25 @@ public static MetricsConfig getDefault() {
     }
   }
 
+  /**

Review comment:
       Can we add a sentence to each method to describe what they do?
   
   ```
   Creates a metrics config from table properties.
   Creates a metrics config for a table.
   ```

##########
File path: core/src/main/java/org/apache/iceberg/MetricsConfig.java
##########
@@ -77,6 +79,14 @@ public static MetricsConfig getDefault() {
   }
 
   public static MetricsConfig fromProperties(Map<String, String> props) {
+    return from(props, null);
+  }
+
+  public static MetricsConfig forTable(Table table) {

Review comment:
       Resolving as this seems to be done.

##########
File path: core/src/main/java/org/apache/iceberg/MetricsConfig.java
##########
@@ -76,7 +78,25 @@ public static MetricsConfig getDefault() {
     }
   }
 
+  /**

Review comment:
       Super nit: Also, case-sensitivity in param docs seems inconsistent. Can 
we fix that? I think we usually use lower case letters unless it is a name.

##########
File path: core/src/main/java/org/apache/iceberg/MetricsConfig.java
##########
@@ -87,6 +107,11 @@ public static MetricsConfig fromProperties(Map<String, 
String> props) {
       spec.defaultMode = 
MetricsModes.fromString(DEFAULT_WRITE_METRICS_MODE_DEFAULT);
     }
 
+    // First set sorted column with sorted column default (can be overridden 
by user)
+    MetricsMode sortedColDefaultMode = 
sortedColumnDefaultMode(spec.defaultMode);

Review comment:
       Looks clean!




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