seddonm1 commented on a change in pull request #9038:
URL: https://github.com/apache/arrow/pull/9038#discussion_r550809056



##########
File path: rust/datafusion/src/physical_plan/expressions.rs
##########
@@ -2414,6 +2417,212 @@ impl PhysicalSortExpr {
     }
 }
 
+/// InList
+#[derive(Debug)]
+pub struct InListExpr {
+    expr: Arc<dyn PhysicalExpr>,
+    list: Vec<Arc<dyn PhysicalExpr>>,
+}
+
+macro_rules! make_contains {
+    ($ARRAY:expr, $LIST_VALUES:expr, $SCALAR_VALUE:ident, $ARRAY_TYPE:ident) 
=> {{
+        let array = $ARRAY.as_any().downcast_ref::<$ARRAY_TYPE>().unwrap();
+
+        let values = $LIST_VALUES
+            .iter()
+            .map(|expr| match expr {
+                ColumnarValue::Scalar(s) => match s {
+                    ScalarValue::$SCALAR_VALUE(Some(v)) => v,
+                    datatype => unimplemented!("Unexpected type {} for 
InList", datatype),
+                },
+                ColumnarValue::Array(_) => {
+                    unimplemented!("InList should not receive Array")
+                }
+            })
+            .collect::<Vec<_>>();
+
+        Ok(ColumnarValue::Array(Arc::new(
+            array
+                .iter()
+                .map(|x| x.map(|x| values.contains(&&x)))

Review comment:
       As to the second problem, `NULL` in the `list` component it gets even 
crazier than your example (Postgres 13.1). What a mess.
   
   ```sql
   SELECT 'a' IN (NULL); -> NULL
   SELECT 'a' IN (NULL, 'a'); -> TRUE
   SELECT 'a' IN (NULL, 'b'); -> NULL
   ```




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

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


Reply via email to