timothyw553 commented on code in PR #18935:
URL: https://github.com/apache/iceberg/pull/18935#discussion_r4718908623


##########
core/src/main/java/org/apache/iceberg/MetricsConfig.java:
##########
@@ -190,6 +202,17 @@ public Set<Integer> struct(Types.StructType struct, 
Iterable<Set<Integer>> field
             return null;
           }
 
+          @Override
+          public Set<Integer> file(Types.FileType file, Iterable<Set<Integer>> 
fieldResults) {
+            for (int offset : FILE_INFERRED_METRIC_ID_OFFSETS) {

Review Comment:
   existing tests only hit limits that include all or none of the inferred file 
fields, so nothing checks stopping mid-file (e.g. limit 3 where `uri` is 
included but `size` and `content_type` are not). could we add this case to 
`TestMetricsConfig`?
   
   ```diff
   +  @Test
   +  void inferredLimitCanStopWithinAFile() {
   +    MetricsConfig config =
   +        MetricsTestUtil.from(
   +            Map.of(TableProperties.METRICS_MAX_INFERRED_COLUMN_DEFAULTS, 
"3"),
   +            FILE_SCHEMA);
   +
   +    assertThat(config.columnMode("photo.uri")).isEqualTo(TRUNCATE_16);
   +    assertThat(config.columnMode("photo.size")).isEqualTo(NONE);
   +    assertThat(config.columnMode("photo.content_type")).isEqualTo(NONE);
   +  }
   ```



##########
api/src/main/java/org/apache/iceberg/Schema.java:
##########
@@ -603,20 +626,33 @@ private List<NestedField> reassignIds(List<NestedField> 
columns, TypeUtil.GetID
     if (getID == null) {
       return columns;
     }
+
     Type res =
         TypeUtil.assignIds(
             StructType.of(columns),
-            oldId -> {
-              int newId = getID.get(oldId);
-              if (newId != oldId) {
-                idsToReassigned.put(oldId, newId);
-                idsToOriginal.put(newId, oldId);
+            new TypeUtil.GetID() {
+              @Override
+              public int get(int oldId) {
+                return recordIfReassigned(oldId, getID.get(oldId));
+              }
+
+              @Override
+              public int get(int oldId, Type type) {

Review Comment:
   looks like nothing tests that `Schema` forwards `type` to `getID.get(oldId, 
type)` here — if this wrapper were simplified to a lambda, the existing tests 
would still pass. could we add a test in `TestSchema` that supplies a typed 
`GetID`, moves a file column (e.g. id 1 to 11), and checks the reassigned ids?



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