askalt commented on code in PR #24159:
URL: https://github.com/apache/datafusion/pull/24159#discussion_r3743703245
##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1216,6 +1219,26 @@ impl DefaultPhysicalPlanner {
}
LogicalPlan::SubqueryAlias(_) => children.one()?,
LogicalPlan::Limit(limit) => {
+ // Try to evaluate skip and fetch expressions.
+ let context = SimplifyContext::builder().build();
+ let simplifier = ExprSimplifier::new(context);
+
+ let skip = match &limit.skip {
+ Some(expr) =>
Some(Box::new(simplifier.simplify(*expr.clone())?)),
+ None => None,
+ };
+
+ let fetch = match &limit.fetch {
+ Some(expr) =>
Some(Box::new(simplifier.simplify(*expr.clone())?)),
+ None => None,
+ };
Review Comment:
Can we avoid code duplication here? e.g. create a closure.
##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1216,6 +1219,26 @@ impl DefaultPhysicalPlanner {
}
LogicalPlan::SubqueryAlias(_) => children.one()?,
LogicalPlan::Limit(limit) => {
+ // Try to evaluate skip and fetch expressions.
Review Comment:
Let's add SLT to test these changes.
##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -3683,7 +3684,8 @@ pub enum FetchType {
/// The fetch expression is a literal value.
/// `Literal(None)` means the fetch expression is not provided.
Literal(Option<usize>),
- /// Currently only supports expressions that can be folded into constants.
+ //// Currently supports all expressions that can be evaluated.
+ /// UnsupportedExpr means that the expression is not considered by the
analyzer/optimizer.
Review Comment:
```suggestion
/// UnsupportedExpr means that the expression is not considered by the
logical analyzer/optimizer.
```
--
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]