alamb commented on a change in pull request #1368:
URL: https://github.com/apache/arrow-datafusion/pull/1368#discussion_r757902521



##########
File path: datafusion/tests/sql.rs
##########
@@ -3543,6 +3543,135 @@ async fn explain_analyze_runs_optimizers() {
     assert_contains!(actual, expected);
 }
 
+#[tokio::test]
+async fn tpch_explain_q10() -> Result<()> {

Review comment:
       I agree -- filed https://github.com/apache/arrow-datafusion/issues/1377 
to track this 

##########
File path: datafusion/tests/sql.rs
##########
@@ -3543,6 +3543,135 @@ async fn explain_analyze_runs_optimizers() {
     assert_contains!(actual, expected);
 }
 
+#[tokio::test]
+async fn tpch_explain_q10() -> Result<()> {
+    let mut ctx = ExecutionContext::new();
+
+    register_tpch_csv(&mut ctx, "customer").await?;
+    register_tpch_csv(&mut ctx, "orders").await?;
+    register_tpch_csv(&mut ctx, "lineitem").await?;
+    register_tpch_csv(&mut ctx, "nation").await?;
+
+    let sql = "select
+    c_custkey,
+    c_name,
+    sum(l_extendedprice * (1 - l_discount)) as revenue,
+    c_acctbal,
+    n_name,
+    c_address,
+    c_phone,
+    c_comment
+from
+    customer,
+    orders,
+    lineitem,
+    nation
+where
+        c_custkey = o_custkey
+  and l_orderkey = o_orderkey
+  and o_orderdate >= date '1993-10-01'
+  and o_orderdate < date '1994-01-01'
+  and l_returnflag = 'R'
+  and c_nationkey = n_nationkey
+group by
+    c_custkey,
+    c_name,
+    c_acctbal,
+    c_phone,
+    n_name,
+    c_address,
+    c_comment
+order by
+    revenue desc;";
+
+    let mut plan = ctx.create_logical_plan(sql);
+    plan = ctx.optimize(&plan.unwrap());
+
+    let expected = "\
+    Sort: #revenue DESC NULLS FIRST\
+    \n  Projection: #customer.c_custkey, #customer.c_name, 
#SUM(lineitem.l_extendedprice * Int64(1) - lineitem.l_discount) AS revenue, 
#customer.c_acctbal, #nation.n_name, #customer.c_address, #customer.c_phone, 
#customer.c_comment\
+    \n    Aggregate: groupBy=[[#customer.c_custkey, #customer.c_name, 
#customer.c_acctbal, #customer.c_phone, #nation.n_name, #customer.c_address, 
#customer.c_comment]], aggr=[[SUM(#lineitem.l_extendedprice * Int64(1) - 
#lineitem.l_discount)]]\
+    \n      Join: #customer.c_nationkey = #nation.n_nationkey\
+    \n        Join: #orders.o_orderkey = #lineitem.l_orderkey\
+    \n          Join: #customer.c_custkey = #orders.o_custkey\
+    \n            TableScan: customer projection=Some([0, 1, 2, 3, 4, 5, 7])\
+    \n            Filter: #orders.o_orderdate >= Date32(\"8674\") AND 
#orders.o_orderdate < Date32(\"8766\")\
+    \n              TableScan: orders projection=Some([0, 1, 4]), 
filters=[#orders.o_orderdate >= Date32(\"8674\"), #orders.o_orderdate < 
Date32(\"8766\")]\

Review comment:
       so lovely to see those filters pushed down ❤️ 

##########
File path: datafusion/src/optimizer/filter_push_down.rs
##########
@@ -245,6 +245,9 @@ fn split_members<'a>(predicate: &'a Expr, predicates: &mut 
Vec<&'a Expr>) {
             split_members(left, predicates);
             split_members(right, predicates);
         }
+        Expr::Alias(expr, _) => {

Review comment:
       💯  excellent




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