liukun4515 commented on code in PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#discussion_r977136191


##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -79,10 +79,29 @@ impl OptimizerRule for TypeCoercion {
             const_evaluator,
         };
 
+        let original_expr_names: Vec<Option<String>> = plan
+            .expressions()
+            .iter()
+            .map(|expr| expr.name().ok())
+            .collect();
+
         let new_expr = plan
             .expressions()
             .into_iter()
-            .map(|expr| expr.rewrite(&mut expr_rewrite))
+            .zip(original_expr_names)
+            .map(|(expr, original_name)| {
+                let expr = expr.rewrite(&mut expr_rewrite)?;
+
+                if matches!(expr, Expr::AggregateFunction { .. }) {

Review Comment:
   I think this is just a workround for this issue. We should split the type 
coercion from the optimizer



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

Reply via email to