alamb commented on code in PR #15764:
URL: https://github.com/apache/datafusion/pull/15764#discussion_r2051508492


##########
datafusion/physical-optimizer/src/pruning.rs:
##########
@@ -1215,8 +1215,33 @@ fn is_compare_op(op: Operator) -> bool {
 // For example, casts from string to numbers is not correct.
 // Because the "13" is less than "3" with UTF8 comparison order.
 fn verify_support_type_for_prune(from_type: &DataType, to_type: &DataType) -> 
Result<()> {
-    // TODO: support other data type for prunable cast or try cast
-    if matches!(
+    // Dictionary casts are always supported as long as the value types are 
supported
+    let from_type = match from_type {
+        DataType::Dictionary(_, t) => {
+            return verify_support_type_for_prune(t.as_ref(), to_type)
+        }
+        _ => from_type,
+    };
+    let to_type = match to_type {
+        DataType::Dictionary(_, t) => {
+            return verify_support_type_for_prune(from_type, t.as_ref())
+        }
+        _ => to_type,
+    };
+    // If the types are the same (e.g. after unpacking a dictionary) they are 
supported
+    if from_type == to_type {
+        return Ok(());
+    }
+    // TODO: add an `is_string()` method to DataType

Review Comment:
   👍 



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