jackwener commented on code in PR #4276:
URL: https://github.com/apache/arrow-datafusion/pull/4276#discussion_r1028795494
##########
datafusion/optimizer/src/limit_push_down.rs:
##########
@@ -941,11 +738,41 @@ mod test {
let expected = "Limit: skip=1000, fetch=1000\
\n CrossJoin:\
- \n TableScan: test, fetch=2000\
- \n TableScan: test2, fetch=2000";
+ \n Limit: skip=0, fetch=2000\
+ \n TableScan: test, fetch=2000\
+ \n Limit: skip=0, fetch=2000\
+ \n TableScan: test2, fetch=2000";
- assert_optimized_plan_eq(&plan, expected);
+ assert_optimized_plan_eq(&plan, expected)
+ }
- Ok(())
+ #[test]
+ fn merge_limit_result_empty() -> Result<()> {
+ let scan = test_table_scan()?;
+
+ let plan = LogicalPlanBuilder::from(scan)
+ .limit(0, Some(1000))?
+ .limit(1000, None)?
+ .build()?;
+
+ let expected = "Limit: skip=1000, fetch=0\
+ \n TableScan: test, fetch=1000";
+
+ assert_optimized_plan_eq(&plan, expected)
+ }
+
+ #[test]
+ fn skip_great_than_fetch() -> Result<()> {
+ let scan = test_table_scan()?;
+
+ let plan = LogicalPlanBuilder::from(scan)
+ .limit(0, Some(1))?
+ .limit(1000, None)?
+ .build()?;
+
+ let expected = "Limit: skip=1000, fetch=0\
+ \n TableScan: test, fetch=1000";
+
+ assert_optimized_plan_eq(&plan, expected)
Review Comment:
Original test miss case to confirm merge limit, avoid `overflow` problem.
Add more UT to check them.
--
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]