This is an automated email from the ASF dual-hosted git repository.
jonah pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 06594c79f1 Bug-fix / Limit with_new_exprs() (#13109)
06594c79f1 is described below
commit 06594c79f11d57b88467e9b87e5cb1ac6cf85d88
Author: Berkay Şahin <[email protected]>
AuthorDate: Fri Oct 25 16:50:38 2024 +0300
Bug-fix / Limit with_new_exprs() (#13109)
* Update plan.rs
* Update plan.rs
* Update plan.rs
---
datafusion/expr/src/logical_plan/plan.rs | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/datafusion/expr/src/logical_plan/plan.rs
b/datafusion/expr/src/logical_plan/plan.rs
index 4b42702f24..572285defb 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -936,9 +936,8 @@ impl LogicalPlan {
expr.len()
);
}
- // Pop order is same as the order returned by
`LogicalPlan::expressions()`
- let new_skip = skip.as_ref().and(expr.pop());
- let new_fetch = fetch.as_ref().and(expr.pop());
+ let new_skip = skip.as_ref().and_then(|_| expr.pop());
+ let new_fetch = fetch.as_ref().and_then(|_| expr.pop());
let input = self.only_input(inputs)?;
Ok(LogicalPlan::Limit(Limit {
skip: new_skip.map(Box::new),
@@ -4101,4 +4100,25 @@ digraph {
);
assert_eq!(describe_table.partial_cmp(&describe_table_clone), None);
}
+
+ #[test]
+ fn test_limit_with_new_children() {
+ let limit = LogicalPlan::Limit(Limit {
+ skip: None,
+ fetch: Some(Box::new(Expr::Literal(
+ ScalarValue::new_ten(&DataType::UInt32).unwrap(),
+ ))),
+ input: Arc::new(LogicalPlan::Values(Values {
+ schema: Arc::new(DFSchema::empty()),
+ values: vec![vec![]],
+ })),
+ });
+ let new_limit = limit
+ .with_new_exprs(
+ limit.expressions(),
+ limit.inputs().into_iter().cloned().collect(),
+ )
+ .unwrap();
+ assert_eq!(limit, new_limit);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]