ZENOTME commented on code in PR #880:
URL: https://github.com/apache/iceberg-rust/pull/880#discussion_r1906731431


##########
crates/integrations/datafusion/src/statistics.rs:
##########
@@ -0,0 +1,112 @@
+// 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.
+
+use std::collections::HashMap;
+
+use datafusion::common::stats::Precision;
+use datafusion::common::{ColumnStatistics, Statistics};
+use iceberg::spec::ManifestStatus;
+use iceberg::table::Table;
+use iceberg::Result;
+
+use crate::physical_plan::expr_to_predicate::datum_to_scalar_value;
+
+// Compute DataFusion table statistics for a given table/snapshot
+pub async fn compute_statistics(table: &Table, snapshot_id: Option<i64>) -> 
Result<Statistics> {
+    let file_io = table.file_io();
+    let metadata = table.metadata();
+    let snapshot = table.snapshot(snapshot_id)?;
+
+    let mut num_rows = 0;
+    let mut lower_bounds = HashMap::new();
+    let mut upper_bounds = HashMap::new();
+    let mut null_counts = HashMap::new();
+
+    let manifest_list = snapshot.load_manifest_list(file_io, metadata).await?;
+
+    // For each existing/added manifest in the snapshot aggregate the row 
count, as well as null
+    // count and min/max values.
+    for manifest_file in manifest_list.entries() {
+        let manifest = manifest_file.load_manifest(file_io).await?;

Review Comment:
   > As for point 2, is it not sufficient that I aggregate stats only for 
manifest_entry.status() != ManifestStatus::Deleted below? Put another way is it 
possible for ManifestStatus::Existing | ManifestStatus::Added entries to 
contain some misleading stats?
   
   I think what @liurenjie1024 means is the delete file.🤔 
https://iceberg.apache.org/spec/#delete-formats



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