Col-Waltz opened a new pull request, #16066:
URL: https://github.com/apache/datafusion/pull/16066

   ## Which issue does this PR close?
   
   - Closes https://github.com/apache/datafusion/issues/15291.
   
   ## Rationale for this change
   
   Common_sub_expression_eliminate rule failed with error:
   `SchemaError(FieldNotFound {field: <name>}, valid_fields: []})`
   due to the schema being changed by the second application of
   `find_common_exprs`
       
   As I understood the source of the problem was in sequential call of
   `find_common_exprs`. First call returned original names as `aggr_expr`
   and changed names as `new_aggr_expr`. Second call takes into account
   only `new_aggr_expr` and if names was already changed by first call
   will return changed names as `aggr_expr`(original ones)
   and put them into Projection logic.
       
   ## What changes are included in this PR?
   
   I used existing NamePreserver mechanism to restore original schema names and
   generate Projection with original name at the end of aggregate optimization.
   
   
   ## Are these changes tested?
   
   Yes this changes are tested and I added test to this commit.
   Error emerges not only in PREPARE requests, I created SELECT request which
   causes the same error.
   
   ## Are there any user-facing changes?
   
   No the change only fixes optimization rule.
   


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to