comphead commented on code in PR #6604:
URL: https://github.com/apache/arrow-datafusion/pull/6604#discussion_r1224841241


##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -576,6 +577,47 @@ pub fn to_substrait_rex(
     ),
 ) -> Result<Expression> {
     match expr {
+        Expr::InList(InList {
+            expr,
+            list,
+            negated,
+        }) => {
+            // expr IN (A, B, ...) --> (expr = A) OR (expr = B) OR (expr = C)
+            // negated: expr NOT IN (A, B, ...) --> (expr != A) AND (expr != 
B) AND (expr != C)
+            let op_for_list = match negated {
+                true => Operator::And,
+                false => Operator::Or,
+            };
+            let op_for_list_item = match negated {
+                true => Operator::NotEq,
+                false => Operator::Eq,
+            };
+
+            let substrait_list = list
+                .iter()
+                .map(|x| to_substrait_rex(x, schema, extension_info))
+                .collect::<Result<Vec<Expression>>>()?;
+            let substrait_expr = to_substrait_rex(expr, schema, 
extension_info)?;
+
+            let init_val = make_binary_op_scalar_func(
+                &substrait_expr,
+                &substrait_list[0],

Review Comment:
   substrait_list[0] -> `.first()`? This will return Option so better to check 
if option is defined and return Err if not



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

Reply via email to