cool9850311 commented on code in PR #27669:
URL: https://github.com/apache/datafusion/pull/27669#discussion_r4676795897


##########
datafusion/physical-optimizer/src/projection_pushdown.rs:
##########
@@ -507,6 +508,59 @@ fn leaf_column_name(index: usize) -> String {
     format!("{LEAF_COLUMN_PREFIX}_{index}")
 }
 
+/// Returns the input of `node` if the split may place the leaf projection
+/// below it.
+///
+/// The split gives `node` an input with different columns, so `node` must not
+/// reference its input's columns and must output them unchanged, or the outer
+/// projection's column indices would point at the wrong columns. The arms are
+/// an allowlist: satisfying that is necessary, not sufficient.
+fn split_host_child(node: &Arc<dyn ExecutionPlan>) -> Option<&Arc<dyn 
ExecutionPlan>> {
+    if let Some(repartition) = node.downcast_ref::<RepartitionExec>() {
+        // Hash and Range partitioning reference columns by index, which would
+        // have to be remapped against the rewritten child schema. Round robin
+        // carries no column references, and is what `EnsureRequirements`
+        // inserts here.
+        if !matches!(repartition.partitioning(), 
Partitioning::RoundRobinBatch(_)) {
+            return None;
+        }
+        Some(repartition.input())
+    } else if let Some(limit) = node.downcast_ref::<GlobalLimitExec>() {
+        // A source that supports skip pushdown wraps its scan in this for the
+        // skip, which leaves the projection holding the leaf above it.
+        Some(limit.input())
+    } else if let Some(coalesce) = 
node.downcast_ref::<CoalescePartitionsExec>() {
+        // A scan with more than one file group puts this between that limit
+        // and the source.
+        Some(coalesce.input())
+    } else {
+        None
+    }
+}
+
+/// The hosts between a projection and the child the split places the leaf
+/// projection on.

Review Comment:
   It's actually a pass-through node, which move the file_row_index() down to 
DataSourceExec.
   I can rename it to pass-through.



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