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


##########
datafusion/core/src/physical_optimizer/pruning.rs:
##########
@@ -495,21 +501,40 @@ fn rewrite_expr_to_prunable(
     }
 
     match column_expr {
+        // col op lit()
+        Expr::Column(_) => Ok((column_expr.clone(), op, scalar_expr.clone())),
         // `cast(col) op lit()`
         Expr::Cast { expr, data_type } => {
-            let (left, op, right) = rewrite_expr_to_prunable(expr, op, 
scalar_expr)?;
-            Ok((cast(left, data_type.clone()), op, right))
+            let from_type = expr.get_type(&schema)?;
+            if support_type_for_prune(&from_type, data_type) {
+                let (left, op, right) =
+                    rewrite_expr_to_prunable(expr, op, scalar_expr, schema)?;
+                Ok((cast(left, data_type.clone()), op, right))
+            } else {
+                return Err(DataFusionError::Plan(format!(
+                    "Cast with from type {} to type {} is not supported",
+                    from_type, data_type
+                )));
+            }

Review Comment:
   good point



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