sunchao commented on code in PR #7598:
URL: https://github.com/apache/datafusion-comet/pull/7598#discussion_r4556810070


##########
native/core/src/execution/operators/dynamic_filter/min_max/row_group_limit.rs:
##########
@@ -0,0 +1,67 @@
+// 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.
+
+//! Limit the work performed by DataFusion's live row-group pruner.
+
+use std::sync::Arc;
+
+use datafusion::datasource::physical_plan::FileSource;
+use datafusion::datasource::source::DataSourceExec;
+use datafusion::physical_plan::ExecutionPlan;
+
+use super::super::parquet_reader::concrete_parquet_source;
+
+// DataFusion 55.2 rechecks the entire unread tail at every row-group boundary,
+// even when the predicate has not changed. Until that work is bounded 
upstream,
+// cap each eligible file rather than merely throttling aggregate updates.
+pub(super) const MAX_ROW_GROUPS_PER_FILE: usize = 64;
+
+pub(super) async fn within_row_group_limit(
+    input: &Arc<dyn ExecutionPlan>,
+    partition: usize,
+) -> bool {
+    let Some(scan) = input.downcast_ref::<DataSourceExec>() else {
+        return false;
+    };
+    let Some((config, source, _)) = concrete_parquet_source(scan) else {
+        return false;
+    };
+    let Some(factory) = source.parquet_file_reader_factory() else {
+        return false;
+    };
+    let Some(group) = config.file_groups.get(partition) else {
+        return false;
+    };
+    // Use the native reader's footer cache where available. If any file is
+    // oversized, keep ordinary aggregation for this execution. Let normal
+    // decoding report metadata errors in its original order and context.
+    for file in group.files() {
+        let Ok(mut reader) = factory.create_reader(
+            partition,
+            file.clone(),
+            file.metadata_size_hint,

Review Comment:
   [P2] Preserve the scan’s footer hint during row-group preflight
   
   This passes only the per-file hint to the reader factory. For files without 
an override, the ordinary native scan supplies its 512 KiB hint, but the new 
preflight opens the cold metadata without it. On this exact head, the pinned 
loader took three storage range requests for a cold 386-byte, one-row-group 
Parquet file without the hint and one with it. In the separate 16-file 
descending MIN fixture with metadata prefetch disabled, the wrapper cold-loaded 
all 16 footers before scanning, then hit the cache for all 16 and pruned zero 
groups. The ordinary scan’s hint and the loader are unchanged from the merge 
base.
   
   Use the same effective hint as normal scan open, including the source hint 
when there is no per-file override, so this preflight does not add round trips 
before any rows can be read.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to