ming535 commented on code in PR #2823:
URL: https://github.com/apache/arrow-datafusion/pull/2823#discussion_r913716649


##########
datafusion/optimizer/src/eliminate_limit.rs:
##########
@@ -35,35 +39,98 @@ impl EliminateLimit {
     }
 }
 
+/// Ancestor indicates the current ancestor in the LogicalPlan tree
+/// when traversing down related to "eliminate limit".
+enum Ancestor {
+    /// Limit
+    FromLimit { skip: Option<usize> },
+    /// Other nodes that don't affect the adjustment of "Limit"
+    NotRelevant,
+}
+
+/// replaces LIMIT 0 with an [LogicalPlan::EmptyRelation]
+/// replaces LIMIT node whose ancestor LIMIT's skip is greater than or equal 
to current's fetch
+/// with an [LogicalPlan::EmptyRelation]
+fn eliminate_limit(
+    _optimizer: &EliminateLimit,
+    ancestor: &Ancestor,
+    plan: &LogicalPlan,
+    _optimizer_config: &OptimizerConfig,
+) -> Result<LogicalPlan> {
+    match plan {

Review Comment:
   `SELECT * FROM (SELECT * FROM test_a LIMIT 5) AS test_b OFFSET 5;`
   In the above query, the current plan is the one with only `fetch` (the 
subquery).
   
   I thought when the current node is `Limit` with only `skip`, it should be 
handled the same as `Projection`, `Sort`.



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