Jefffrey commented on code in PR #5110:
URL: https://github.com/apache/arrow-rs/pull/5110#discussion_r1405286971


##########
parquet/src/column/writer/mod.rs:
##########
@@ -703,6 +725,35 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> 
{
             (Some(min), Some(max)) => {
                 update_min(&self.descr, &min, &mut 
self.column_metrics.min_column_value);
                 update_max(&self.descr, &max, &mut 
self.column_metrics.max_column_value);
+
+                // Check if min/max are still ascending/descending across pages
+                // Null pages aren't considered in this sort order
+                let null_page = (self.page_metrics.num_buffered_rows as u64)
+                    == self.page_metrics.num_page_nulls;
+                if !null_page {
+                    if let Some((latest_min, latest_max)) = 
&self.latest_non_null_data_page_min_max
+                    {
+                        if self.data_page_boundary_ascending {
+                            // If latest min/max are greater than new min/max 
then not ascending anymore
+                            let not_ascending = compare_greater(&self.descr, 
latest_min, &min)
+                                || compare_greater(&self.descr, latest_max, 
&max);
+                            if not_ascending {
+                                self.data_page_boundary_ascending = false;
+                            }
+                        }
+
+                        if self.data_page_boundary_descending {
+                            // If new min/max are greater than latest min/max 
then not descending anymore
+                            let not_descending = compare_greater(&self.descr, 
&min, latest_min)
+                                || compare_greater(&self.descr, &max, 
latest_max);
+                            if not_descending {
+                                self.data_page_boundary_descending = false;
+                            }
+                        }
+                    }
+                    self.latest_non_null_data_page_min_max = 
Some((min.clone(), max.clone()));
+                }

Review Comment:
   Tried putting the incremental check here instead of inside 
`update_column_offset_index(..)` as I couldn't figure out an easy way to get 
the `T: ParquetValueType` out of a `Statistics` enum
   
   One caveat about putting this check here is that it compares the min/maxes 
**before** truncation occurs, though I _think_ this should still be ok.



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

Reply via email to