AssHero commented on code in PR #2823:
URL: https://github.com/apache/arrow-datafusion/pull/2823#discussion_r913725374
##########
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:
The ancestor LIMIT node is OFFSET 5 for query "SELECT * FROM (SELECT * FROM
test_a LIMIT 5) AS test_b OFFSET 5".
For this case, we should use 5 as ancestor's skip to optimizer inputs.
--
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]