mbutrovich commented on code in PR #24522:
URL: https://github.com/apache/datafusion/pull/24522#discussion_r3823809763


##########
datafusion/datasource-parquet/src/projection_read_plan.rs:
##########
@@ -621,130 +628,91 @@ fn build_read_plan_with_cast_clipping(
         // arrow schema). If not, never risk a wrong mask: read the whole
         // root.
         if root_leaves.len() != count_leaves(physical_type) {
-            fallback_roots.insert(root);
+            root_reads.insert(root, RootRead::Full);
             continue;
         }
 
         match clip_for_cast(physical_type, &access.target_type) {
             Some((kept_offsets, _pruned_type)) => {
-                kept_offsets_by_root
+                if let RootRead::Partial(offsets) = root_reads
                     .entry(root)
-                    .or_default()
-                    .extend(kept_offsets);
+                    .or_insert_with(|| RootRead::Partial(BTreeSet::new()))
+                {
+                    offsets.extend(kept_offsets);
+                }
             }
             // Nothing prunable for this cast: every leaf is consumed.
             None => {
-                kept_offsets_by_root.remove(&root);
-                fallback_roots.insert(root);
+                root_reads.insert(root, RootRead::Full);
             }
         }
     }
 
-    // Add leaves reached through `get_field` to cast roots. The resolver
-    // returns absolute Parquet leaf indices; convert them back to offsets in
-    // their root so they can share the same union as cast clipping.
+    // Add every `get_field` root before resolving leaves. If an access matches
+    // no leaf, finalization safely falls back to a full read for that root.

Review Comment:
   If it fixes a bug can we get a regression test?



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