avantgardnerio commented on code in PR #3482:
URL: https://github.com/apache/arrow-datafusion/pull/3482#discussion_r972059824


##########
datafusion/core/tests/sql/subqueries.rs:
##########
@@ -289,6 +289,139 @@ async fn tpch_q17_correlated() -> Result<()> {
     Ok(())
 }
 
+// Fix for issue#78 join predicates from inside of OR expr also pulled up 
properly.
+#[tokio::test]
+async fn tpch_q19_pull_predicates_to_innerjoin() -> Result<()> {
+    let ctx = SessionContext::new();
+
+    register_tpch_csv(&ctx, "part").await?;
+    register_tpch_csv(&ctx, "lineitem").await?;
+
+    let sql = r#"
+select
+    sum(l_extendedprice* (1 - l_discount)) as revenue
+from
+    lineitem,
+    part
+where
+    (
+                p_partkey = l_partkey
+            and p_brand = 'Brand#12'
+            and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
+            and l_quantity >= 1 and l_quantity <= 1 + 10
+            and p_size between 1 and 5
+            and l_shipmode in ('AIR', 'AIR REG')
+            and l_shipinstruct = 'DELIVER IN PERSON'
+        )
+   or
+    (
+                p_partkey = l_partkey
+            and p_brand = 'Brand#23'
+            and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
+            and l_quantity >= 10 and l_quantity <= 10 + 10
+            and p_size between 1 and 10
+            and l_shipmode in ('AIR', 'AIR REG')
+            and l_shipinstruct = 'DELIVER IN PERSON'
+        )
+   or
+    (
+                p_partkey = l_partkey
+            and p_brand = 'Brand#34'
+            and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
+            and l_quantity >= 20 and l_quantity <= 20 + 10
+            and p_size between 1 and 15
+            and l_shipmode in ('AIR', 'AIR REG')
+            and l_shipinstruct = 'DELIVER IN PERSON'
+        );"#;
+
+    // assert plan
+    let plan = ctx.create_logical_plan(sql).unwrap();

Review Comment:
   There should be no `unwraps` in optimizer rules. @andygrove and others have 
been actively making PRs to remove them, based on some fuzzing results where 
things that were never supposed to happen kept happening.



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