amogh-jahagirdar commented on code in PR #12450:
URL: https://github.com/apache/iceberg/pull/12450#discussion_r2152802240


##########
api/src/main/java/org/apache/iceberg/actions/ComputePartitionStats.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.actions;
+
+import org.apache.iceberg.PartitionStatisticsFile;
+
+/**
+ * An action that computes and writes the partition statistics of an Iceberg 
table. Current snapshot
+ * is used by default.
+ */
+public interface ComputePartitionStats
+    extends Action<ComputePartitionStats, ComputePartitionStats.Result> {

Review Comment:
   I'm still skeptical about keeping these separate; imo there's a few good 
arguments for combining the procedures:
   
   1. the examples @karuppayya provided for 
[Hive](https://cwiki.apache.org/confluence/display/hive/statsdev#StatsDev-Examples),
 
[Spark](https://spark.apache.org/docs/latest/sql-ref-syntax-aux-analyze-table.html),
 [Trino](https://trino.io/docs/current/sql/analyze.html#examples) indicate that 
at least at the SQL level there is precedence for a common `ANALYZE` for both 
columnar and partition stats.
    I think it also makes sense at the Iceberg action API level to follow the 
same structure since users generally just think in terms of "generate these 
stats that will help my performance" (put another way "partitions are part of 
my table") and we can give the optionality to power users to choose which stats 
they want to collect. 
   
   3. I am not super concerned around the `columns` API not applying for 
partitions, by itself that doesn't seem like a strong justification to have 2 
completely separate actions.
   Fundamentally, I think it'll be clear in the combined procedure that users 
express columns for the stats they want to collect and it's clear that 
partition stats are independent
   
   What I'm kind of envisioning:
   
   ```
   
   // Generate NDV stats for "foo", "bar" and partition stats at snapshot 1234
   action.computeTableStats(table).columns("foo", 
"bar").snapshot(1234L).withPartitionStats().commit()
   
   // Generate NDV stats for "foo", "bar" at snapshot 1234
   action.computeTableStats(table).columns("foo", 
"bar").snapshot(1234L).commit()
   
   // Generate NDV stats for "foo", "bar" and partition stats at snapshot 1234
   action.computeTableStats(table).snapshot(1234L).withPartitionStats().commit()
   
   // Generate NDV stats for all columns at snapshot 1234
   action.computeTableStats(table).snapshot(1234L).commit()
   
   
   // Generate only partition stats for snapshot 1234
   action.computeTableStats(table).withOnlyPartitionStats().commit()
   
   ```
   
   The only additional slight awkwardness is in `withOnlyPartitionStats` (which 
if columns are specified along with this option we throw) but this is very 
minimal imo. It's also easier down the line to change behaviors of the 
different options and defaults of the procedure than potentially re-create 
entirely new actions imo.
   
   4.  Whether partition stats supports incremental computation today and table 
stats doesn't, seems like an implementation detail we can hide and is 
independent of the API imo. The implementation will choose the incremental 
computation if it's possible otherwise it won't. That's not a user opt in 
option. Besides, I think we probably could support incremental NDV computation 
down the line? 



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