aokolnychyi commented on code in PR #8803:
URL: https://github.com/apache/iceberg/pull/8803#discussion_r1382331393


##########
core/src/main/java/org/apache/iceberg/util/ContentFileUtil.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import java.util.Set;
+import org.apache.iceberg.ContentFile;
+
+public class ContentFileUtil {
+  private ContentFileUtil() {}
+
+  /**
+   * Copies the {@link ContentFile} with the specific stat settings.
+   *
+   * @param file a generic data file to copy.
+   * @param withStats whether to keep any stats
+   * @param columnsToKeepStats a set of column ids to keep stats. If empty or 
<code>null</code> then
+   *     every column stat is kept.

Review Comment:
   I find this logic a bit hard to follow cause we control the behavior using 
two variables. Any way we can simplify that? We could have something like below.
   
   ```
   Scan.java
   
   includeColumnStats() -> include all stats
   includeColumnStats(Collection<String> requestedColumns) -> include only 
stats for requested columns
   
   ContentFile.java
   
   copy() -> copy preserving all loaded stats (existing)
   copyWithoutStats() -> copy without any loaded stats (existing)
   copy(boolean withStats) -> calls either copy() or copyWithoutStats() 
(existing)
   copyWithStats(Collection<String> requestedColumns) -> copy with stats only 
for requested columns
   ```
   
   We can then maintain a list of columns to project stats in our scans or in 
the scan context object.
   - A collection with a single element `*` means we will call `copy()` on 
files.
   - Null or empty collection means we will call `copyWithoutStats()` on files.
   - A collection with column names means we will call 
`copyWithStats(requestedColumns)` on files.
   
   All of the logic above can be incapsulated in a single copy method in our 
base scan.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to