You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/12 11:24:49 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule

alamb commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1020749024


##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -292,6 +296,25 @@ fn is_support_data_type(data_type: &DataType) -> bool {
     )
 }
 
+fn is_decimal_type(dt: &DataType) -> bool {
+    matches!(dt, DataType::Decimal128(_, _))
+}
+
+fn is_unsigned_type(dt: &DataType) -> bool {
+    matches!(
+        dt,
+        DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64
+    )
+}
+
+/// Until https://github.com/apache/arrow-rs/issues/1043 is done
+/// (support for unsigned <--> decimal casts) we also don't do that
+/// kind of cast in this optimizer
+fn is_unsupported_cast(dt1: &DataType, dt2: &DataType) -> bool {

Review Comment:
   I found this with the test (which failed when it tried to invoke the arrow cast kernels for decimal <--> unsigned)



##########
datafusion/core/tests/sql/joins.rs:
##########
@@ -1428,9 +1428,9 @@ async fn reduce_left_join_1() -> Result<()> {
         "Explain [plan_type:Utf8, plan:Utf8]",
         "  Projection: t1.t1_id, t1.t1_name, t1.t1_int, t2.t2_id, t2.t2_name, t2.t2_int [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
         "    Inner Join: t1.t1_id = t2.t2_id [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
-        "      Filter: CAST(t1.t1_id AS Int64) < Int64(100) [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N]",

Review Comment:
   🎉  the casts have been removed!



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org