aectaan commented on code in PR #23288:
URL: https://github.com/apache/datafusion/pull/23288#discussion_r3520243884


##########
datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/sort_pushdown.rs:
##########
@@ -1042,6 +1054,77 @@ enum RequirementsCompatibility {
     NonCompatible,
 }
 
+/// Attempts to push parent ordering requirements through a [`ProjectionExec`].
+///
+/// This is safe when every required sort expression refers to a projected 
output
+/// column that is backed by a simple input column. In that case, the 
requirement
+/// can be remapped from the projection output schema to the projection input
+/// schema while preserving the original sort options.
+///
+/// For example, a parent requirement on `a@2` over:
+///
+/// ```text
+/// ProjectionExec: expr=[c@2 as c, b@1 as b, a@0 as a]
+/// ```
+///
+/// is remapped to a child requirement on `a@0`.
+///
+/// The implementation is intentionally conservative: computed projection
+/// expressions and non-column sort expressions are not pushed down. Returning
+/// `Ok(None)` leaves sorting above the projection, preserving correctness.
+fn handle_projection_pushdown(

Review Comment:
   Yeah, but it's more permissive. It filters out all the expressions that are 
not `Column`'s. This one don't go if any expression is not `Column`. 
   
   I reused `remap_requirement_through_projection` inside the 
`handle_projection_pushdown`. 
   
   `handle_projection_pushdown` just adds additional check layer



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