zhuqi-lucas commented on code in PR #14245:
URL: https://github.com/apache/datafusion/pull/14245#discussion_r1929652858


##########
datafusion/sqllogictest/test_files/joins.slt:
##########
@@ -4247,8 +4247,10 @@ logical_plan
 physical_plan
 01)CoalesceBatchesExec: target_batch_size=3, fetch=2
 02)--HashJoinExec: mode=CollectLeft, join_type=Full, on=[(c1@0, c1@0)]
-03)----MemoryExec: partitions=1, partition_sizes=[1]
-04)----MemoryExec: partitions=1, partition_sizes=[1]
+03)----GlobalLimitExec: skip=0, fetch=2

Review Comment:
   Hi @alamb :
   I looked into the code about the push down for join:
   
   ```rust
   /// Adds a limit to the inputs of a join, if possible
   fn push_down_join(mut join: Join, limit: usize) -> Transformed<Join> {
       use JoinType::*;
   
       fn is_no_join_condition(join: &Join) -> bool {
           join.on.is_empty() && join.filter.is_none()
       }
   
       let (left_limit, right_limit) = if is_no_join_condition(&join) {
           match join.join_type {
               Left | Right | Full | Inner => (Some(limit), Some(limit)),
               LeftAnti | LeftSemi | LeftMark => (Some(limit), None),
               RightAnti | RightSemi => (None, Some(limit)),
           }
       } else {
           match join.join_type {
               Left => (Some(limit), None),
               Right => (None, Some(limit)),
               Full => (Some(limit), Some(limit)),
               _ => (None, None),
           }
       };
   
       if left_limit.is_none() && right_limit.is_none() {
           return Transformed::no(join);
       }
       if let Some(limit) = left_limit {
           join.left = make_arc_limit(0, limit, join.left);
       }
       if let Some(limit) = right_limit {
           join.right = make_arc_limit(0, limit, join.right);
       }
       Transformed::yes(join)
   }
   ```
   
   I think it's safe we just want to limit any result, we don't care about 
which line to return for the optimization.
   
   If we want to get the accurate limit same with not limit, i think we need to 
remove those push down join optimization?



-- 
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

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

Reply via email to