adriangb commented on code in PR #19050:
URL: https://github.com/apache/datafusion/pull/19050#discussion_r2603228481


##########
datafusion/physical-expr/src/expressions/in_list.rs:
##########
@@ -355,6 +386,57 @@ impl InListExpr {
             Some(instantiate_static_filter(array)?),
         ))
     }
+
+    /// Create a new InList expression with a static filter for constant list 
expressions.
+    ///
+    /// This validates data types, evaluates the list as constants, and uses 
specialized
+    /// StaticFilter implementations for better performance (e.g., 
Int32StaticFilter for Int32).
+    ///
+    /// Returns an error if data types don't match or if the list contains 
non-constant expressions.
+    pub fn try_from_static_filter(
+        expr: Arc<dyn PhysicalExpr>,
+        list: Vec<Arc<dyn PhysicalExpr>>,
+        negated: bool,
+        schema: &Schema,
+    ) -> Result<Self> {
+        // Check the data types match
+        let expr_data_type = expr.data_type(schema)?;
+        for list_expr in list.iter() {
+            let list_expr_data_type = list_expr.data_type(schema)?;
+            assert_or_internal_err!(
+                DFSchema::datatype_is_logically_equal(
+                    &expr_data_type,
+                    &list_expr_data_type
+                ),
+                "The data type inlist should be same, the value type is 
{expr_data_type}, one of list expr type is {list_expr_data_type}"
+            );
+        }
+
+        match try_evaluate_constant_list(&list, schema) {
+            Ok(in_array) => Ok(Self::new(
+                expr,
+                list,
+                negated,
+                Some(instantiate_static_filter(in_array)?),
+            )),
+            Err(_) => {

Review Comment:
   renamed and refactored to Result<Option<>> as you suggested



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to