Lordworms commented on code in PR #13054:
URL: https://github.com/apache/datafusion/pull/13054#discussion_r1813994423


##########
datafusion/physical-plan/src/joins/dynamic_filters.rs:
##########
@@ -243,6 +231,65 @@ impl DynamicFilterInfo {
     }
 }
 
+macro_rules! process_min_max {
+    ($ARRAYS:expr, $ARRAY_TYPE:ty, $SCALAR_TY:ident, $NATIVE_TYPE:ty) => {{
+        let mut min_val: Option<$NATIVE_TYPE> = None;
+        let mut max_val: Option<$NATIVE_TYPE> = None;
+
+        for array in $ARRAYS {
+            if let Some(primitive_array) = 
array.as_any().downcast_ref::<$ARRAY_TYPE>() {
+                let batch_min = min(primitive_array);
+                let batch_max = max(primitive_array);
+
+                min_val = match (min_val, batch_min) {
+                    (Some(a), Some(b)) => Some(if a.is_lt(b) { a } else { b }),
+                    (None, Some(b)) => Some(b),
+                    (Some(a), None) => Some(a),
+                    (None, None) => None,
+                };
+
+                max_val = match (max_val, batch_max) {
+                    (Some(a), Some(b)) => Some(if a.is_gt(b) { a } else { b }),
+                    (None, Some(b)) => Some(b),
+                    (Some(a), None) => Some(a),
+                    (None, None) => None,
+                };
+            }
+        }
+        Ok((
+            ScalarValue::$SCALAR_TY(min_val),
+            ScalarValue::$SCALAR_TY(max_val),
+        ))
+    }};
+}
+
+/// Currently only support numeric data types so generate a range filter
+fn compute_min_max_from_batches(
+    arrays: &[Arc<dyn Array>],
+) -> Result<(ScalarValue, ScalarValue), DataFusionError> {
+    if arrays.is_empty() {
+        return exec_err!("should not be an empty array");
+    }
+
+    let data_type = arrays[0].data_type();
+    match data_type {
+        DataType::Int8 => process_min_max!(arrays, Int8Array, Int8, i8),

Review Comment:
   I'll add it.



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