haohuaijin opened a new issue, #14204: URL: https://github.com/apache/datafusion/issues/14204
### Describe the bug see the plan ``` | physical_plan after OutputRequirements | GlobalLimitExec: skip=0, fetch=10 | | | ProjectionExec: expr=[a@2 as a, b@3 as b, a@0 as a, b@1 as b] | | | CrossJoinExec | | | GlobalLimitExec: skip=0, fetch=1 | | | MemoryExec: partitions=1, partition_sizes=[1] | | | GlobalLimitExec: skip=0, fetch=10 | | | MemoryExec: partitions=1, partition_sizes=[1] | | | | | physical_plan after LimitAggregation | SAME TEXT AS ABOVE | | physical_plan after ProjectionPushdown | SAME TEXT AS ABOVE | | physical_plan after LimitPushdown | ProjectionExec: expr=[a@2 as a, b@3 as b, a@0 as a, b@1 as b] | | | GlobalLimitExec: skip=0, fetch=10 | | | CrossJoinExec | | | MemoryExec: partitions=1, partition_sizes=[1] | | | MemoryExec: partitions=1, partition_sizes=[1] ``` ### To Reproduce ```sql > create table t(a int, b int) as values (1,2), (2,3), (3,4); 0 row(s) fetched. Elapsed 0.036 seconds. > select * from t as t1 join (select * from t limit 1) limit 10; +---+---+---+---+ | a | b | a | b | +---+---+---+---+ | 1 | 2 | 1 | 2 | | 2 | 3 | 1 | 2 | | 3 | 4 | 1 | 2 | | 1 | 2 | 2 | 3 | | 2 | 3 | 2 | 3 | | 3 | 4 | 2 | 3 | | 1 | 2 | 3 | 4 | | 2 | 3 | 3 | 4 | | 3 | 4 | 3 | 4 | +---+---+---+---+ 9 row(s) fetched. Elapsed 0.013 seconds. ``` ### Expected behavior check in datafusion v43, v44 and main, both have this problem ### Additional context if add a order by, the result will correct ```sql > create table t(a int, b int) as values (1,2), (2,3), (3,4); 0 row(s) fetched. Elapsed 0.036 seconds. > select * from t as t1 join (select * from t limit 1) limit 10; +---+---+---+---+ | a | b | a | b | +---+---+---+---+ | 1 | 2 | 1 | 2 | | 2 | 3 | 1 | 2 | | 3 | 4 | 1 | 2 | | 1 | 2 | 2 | 3 | | 2 | 3 | 2 | 3 | | 3 | 4 | 2 | 3 | | 1 | 2 | 3 | 4 | | 2 | 3 | 3 | 4 | | 3 | 4 | 3 | 4 | +---+---+---+---+ 9 row(s) fetched. Elapsed 0.013 seconds. > select * from t as t1 join (select * from t order by a limit 1) limit 10; +---+---+---+---+ | a | b | a | b | +---+---+---+---+ | 1 | 2 | 1 | 2 | | 2 | 3 | 1 | 2 | | 3 | 4 | 1 | 2 | +---+---+---+---+ 3 row(s) fetched. Elapsed 0.014 seconds. ``` -- 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: github-unsubscr...@datafusion.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org