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


##########
datafusion/optimizer/src/decorrelate_where_in.rs:
##########
@@ -220,10 +220,196 @@ mod tests {
     use crate::test::*;
     use datafusion_common::Result;
     use datafusion_expr::{
-        col, in_subquery, lit, logical_plan::LogicalPlanBuilder, 
not_in_subquery,
+        and, binary_expr, col, in_subquery, lit, 
logical_plan::LogicalPlanBuilder,
+        not_in_subquery, or, Operator,
     };
     use std::ops::Add;
 
+    fn assert_optimized_plan_equal(plan: &LogicalPlan, expected: &str) -> 
Result<()> {
+        assert_optimized_plan_eq_display_indent(
+            Arc::new(DecorrelateWhereIn::new()),
+            plan,
+            expected,
+        );
+        Ok(())
+    }
+
+    fn test_subquery_with_name(name: &str) -> Result<Arc<LogicalPlan>> {
+        let table_scan = test_table_scan_with_name(name)?;
+        Ok(Arc::new(
+            LogicalPlanBuilder::from(table_scan)
+                .project(vec![col("c")])?
+                .build()?,
+        ))
+    }
+
+    /// Test for several IN subquery expressions
+    #[test]
+    fn in_subquery_multiple() -> Result<()> {
+        let table_scan = test_table_scan()?;
+        let plan = LogicalPlanBuilder::from(table_scan)
+            .filter(and(
+                in_subquery(col("c"), test_subquery_with_name("sq_1")?),
+                in_subquery(col("b"), test_subquery_with_name("sq_2")?),
+            ))?
+            .project(vec![col("test.b")])?
+            .build()?;
+
+        let expected = "Projection: test.b [b:UInt32]\
+        \n  LeftSemi Join: test.b = __sq_2.c [a:UInt32, b:UInt32, c:UInt32]\

Review Comment:
   nice 👍 



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