alamb commented on code in PR #10974:
URL: https://github.com/apache/datafusion/pull/10974#discussion_r1644594732


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -951,6 +939,54 @@ impl OptimizerRule for PushDownFilter {
     }
 }
 
+/// return transformed projection plan and optinal filter's predicate

Review Comment:
   This is a nice refactor. While reading it I figured it might also be nice to 
improve the documenatation
   
   ```suggestion
   /// Attempts to push `predicate` into a `FilterExec` below `projection
   /// 
   /// # Returns 
   /// (plan, remaining_predicate)
   ///
   /// `plan` is a LogicalPlan for `projection` with possibly a new FilterExec 
below it.
   /// `remaining_predicate` is any part of the predicate that could not be 
pushed down
   ///
   /// # Example
   ///
   /// Pushing a predicate like `foo=5 AND bar=6` with an input plan like this:
   ///
   /// ```text
   /// Projection(foo, c+d as bar) 
   /// ```
   ///
   /// Might result in returning `remaining_predicate` of `bar=6` and a plan 
like
   ///
   /// ```text
   /// Projection(foo, c+d as bar)
   ///  Filter(foo=5)
   ///   ...
   /// ```
   
   ```



##########
datafusion/sqllogictest/test_files/push_down_filter.slt:
##########
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#   http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Test push down filter
+
+statement ok
+set datafusion.explain.logical_plan_only = true;
+
+statement ok
+CREATE TABLE IF NOT EXISTS v AS VALUES(1,[1,2,3]),(2,[3,4,5]);
+
+# filter plan is pushed down into projection plan

Review Comment:
   Can you please also add a negative test with a predicate on `uc2`? Something 
like
   
   ```sql
   explain select uc2 from (select unnest(column2) as uc2, column1 from v) 
where uc2  > 3;
   ```
   
   it might also be good to add tests to actually run those queries



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to