xudong963 commented on code in PR #15289:
URL: https://github.com/apache/datafusion/pull/15289#discussion_r2002964212


##########
datafusion/datasource-parquet/src/file_format.rs:
##########
@@ -834,49 +830,65 @@ pub fn statistics_from_parquet_meta_calc(
         file_schema = merged;
     }
 
-    statistics.column_statistics = if has_statistics {
-        let (mut max_accs, mut min_accs) = create_max_min_accs(&table_schema);
-        let mut null_counts_array =
-            vec![Precision::Exact(0); table_schema.fields().len()];
-
-        table_schema
-            .fields()
-            .iter()
-            .enumerate()
-            .for_each(|(idx, field)| {
-                match StatisticsConverter::try_new(
-                    field.name(),
-                    &file_schema,
-                    file_metadata.schema_descr(),
-                ) {
-                    Ok(stats_converter) => {
-                        summarize_min_max_null_counts(
-                            &mut min_accs,
-                            &mut max_accs,
-                            &mut null_counts_array,
-                            idx,
-                            num_rows,
-                            &stats_converter,
-                            row_groups_metadata,
-                        )
-                        .ok();
-                    }
-                    Err(e) => {
-                        debug!("Failed to create statistics converter: {}", e);
-                        null_counts_array[idx] = Precision::Exact(num_rows);
-                    }
+    // Initialize for column statistics
+    let mut max_accs = vec![None; table_schema.fields().len()];
+    let mut min_accs = vec![None; table_schema.fields().len()];
+    let mut null_counts_array = vec![Precision::Absent; 
table_schema.fields().len()];
+
+    // First, identify which columns actually have statistics
+    // Then if they do, calculate the statistics
+    for (idx, field) in table_schema.fields().iter().enumerate() {
+        match StatisticsConverter::try_new(
+            field.name(),
+            &file_schema,
+            file_metadata.schema_descr(),
+        ) {
+            Ok(stats_converter) => {
+                let parquet_index = stats_converter.parquet_column_index();
+                if parquet_index.is_none() {
+                    continue;

Review Comment:
   CI broken because of the change.



-- 
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: github-unsubscr...@datafusion.apache.org

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


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

Reply via email to