masonh22 opened a new pull request, #25577:
URL: https://github.com/apache/datafusion/pull/25577

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes #.
   
   ## Rationale for this change
   
   #22298 updated the logical plan optimizer to apply optimization rules in 
place to avoid `Arc` unwrap/rewraps with a new `map_children_mut()` function.  
This function unconditionally updates the children of all logical plan nodes 
except for `LogicalPlan::Extension` nodes.  For `Extension` nodes, it only 
updates the children if the mapping function returns `true` for any of the 
children, signifying that a child was updated.
   
   When the `EliminateLimit` rule prunes a limit that has 0 skip and fetch, it 
modifies the node but does not return that it modified anything.  This is fine 
for every case except for if the limit is underneath a `LogicalPlan::Extension` 
node, since it that case we ignore the output from the rule.
   
   ## What changes are included in this PR?
   
   This change adds a failing test, a fix to `EliminateLimit`, and changes 
`map_children_mut()` to unconditionally update the children of 
`LogicalPlan::Extension` nodes.  The change to `map_children_mut()` could be 
left out, but I wouldn't be surprised if there are other optimization rules 
that modify the node without returning `transformed=true`, so this is done to 
avoid finding and fixing all of those cases.
   
   <!--
   There is no need to duplicate the description in the issue here, but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## What is the testing strategy for this PR?
   
   I added a test that replicates the issue and fails without my fixes.
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   Briefly describe how this PR is tested, and point to the specific tests you 
added. For example: 'This new feature is covered by the `sqllogictest` cases 
added in `foo.slt`'.
   
   If this PR does not add tests, explain why. For example, if the change is 
already covered by existing tests, please mention it.
   
   You should also check the `codecov` bot reply on this PR to confirm the 
changed code is exercised.
   -->
   
   ## Are there any user-facing changes?
   
   No
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   


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