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


##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -122,10 +122,6 @@ impl ExprRewriter for UnwrapCastExprRewriter {
                 let right = right.as_ref().clone();
                 let left_type = left.get_type(&self.schema);
                 let right_type = right.get_type(&self.schema);
-                // can't get the data type, just return the expr
-                if left_type.is_err() || right_type.is_err() {
-                    return Ok(expr.clone());
-                }

Review Comment:
   Why we need to remove this code? @alamb 
   From the interface `get_type` which may return error like that:
   
   ```
               Expr::Wildcard => Err(DataFusionError::Internal(
                   "Wildcard expressions are not valid in a logical query 
plan".to_owned(),
               )),
               Expr::QualifiedWildcard { .. } => Err(DataFusionError::Internal(
                   "QualifiedWildcard expressions are not valid in a logical 
query plan"
                       .to_owned(),
               )),
   ```
   
   Do we need to throw the error for this rule, when get an error with 
`get_type` of the expr?
   



##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -122,10 +122,6 @@ impl ExprRewriter for UnwrapCastExprRewriter {
                 let right = right.as_ref().clone();
                 let left_type = left.get_type(&self.schema);
                 let right_type = right.get_type(&self.schema);
-                // can't get the data type, just return the expr
-                if left_type.is_err() || right_type.is_err() {
-                    return Ok(expr.clone());
-                }
                 // Because the plan has been done the type coercion, the left 
and right must be equal
                 let left_type = left_type?;
                 let right_type = right_type?;

Review Comment:
   If we need to throw the error when can't `get_type` of the expr, I think 
this fix maybe reasonable.



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