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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -638,22 +638,26 @@ fn dictionary_coercion(
     preserve_dictionaries: bool,
 ) -> Option<DataType> {
     use arrow::datatypes::DataType::*;
+    let maybe_preserve_dictionaries =
+        |index_type: &Box<DataType>, value_type: DataType| -> DataType {
+            if preserve_dictionaries {
+                Dictionary(index_type.clone(), Box::new(value_type))
+            } else {
+                value_type
+            }
+        };
     match (lhs_type, rhs_type) {
         (
             Dictionary(_lhs_index_type, lhs_value_type),
             Dictionary(_rhs_index_type, rhs_value_type),
         ) => comparison_coercion(lhs_value_type, rhs_value_type),

Review Comment:
   > 02)--FilterExec: CAST(column2@1 AS Dictionary(Int32, Utf8)) = 2
   
   Yes I agree that looks bad. It should be unwrapped. 
   
   Thank you for that example 💯 
   
   Maybe we could  extend 
https://github.com/apache/datafusion/blob/a5ce56831a9ec61e634d1c285c1b28d8c3891503/datafusion/optimizer/src/unwrap_cast_in_comparison.rs#L160
  which handles `CAST(col, ..) = const` for other datatypes 🤔 
   
   I can try to do so later this weekend or



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