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


##########
datafusion/physical-optimizer/src/limit_pushdown.rs:
##########
@@ -146,6 +146,15 @@ pub fn pushdown_limit_helper(
         global_state.skip = skip;
         global_state.fetch = fetch;
 
+        if limit_exec.input().as_any().is::<CoalescePartitionsExec>() {

Review Comment:
   Updated, i confirmed SortPreservingMerge works well with fetch:
   
   
   ```rust
   # Check output plan, expect no "output_ordering" clause in the physical_plan 
-> ParquetExec:
   query TT
   explain with selection as (
       select *
       from test_table
       ORDER BY string_col, int_col limit 1
   )
   select 1 as foo
   from selection
   order by string_col
   limit 1000;
   ----
   logical_plan
   01)Projection: foo
   02)--Sort: selection.string_col ASC NULLS LAST, fetch=1000
   03)----Projection: Int64(1) AS foo, selection.string_col
   04)------SubqueryAlias: selection
   05)--------Projection: test_table.string_col
   06)----------Sort: test_table.string_col ASC NULLS LAST, test_table.int_col 
ASC NULLS LAST, fetch=1
   07)------------TableScan: test_table projection=[int_col, string_col]
   physical_plan
   01)ProjectionExec: expr=[foo@0 as foo]
   02)--ProjectionExec: expr=[1 as foo, string_col@0 as string_col]
   03)----ProjectionExec: expr=[string_col@1 as string_col]
   04)------SortPreservingMergeExec: [string_col@1 ASC NULLS LAST, int_col@0 
ASC NULLS LAST], fetch=1
   05)--------SortExec: TopK(fetch=1), expr=[string_col@1 ASC NULLS LAST, 
int_col@0 ASC NULLS LAST], preserve_partitioning=[true]
   06)----------ParquetExec: file_groups={2 groups: 
[[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_table/0.parquet],
 
[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_table/1.parquet]]},
 projection=[int_col, string_col]
   
   ```



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

Reply via email to