File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
datafusion/proto/src/logical_plan Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -480,7 +480,19 @@ impl AsLogicalPlan for LogicalPlanNode {
480480 into_logical_plan ! ( sort. input, ctx, extension_codec) ?;
481481 let sort_expr: Vec < SortExpr > =
482482 from_proto:: parse_sorts ( & sort. expr , ctx, extension_codec) ?;
483- LogicalPlanBuilder :: from ( input) . sort ( sort_expr) ?. build ( )
483+ let fetch = if sort. fetch < 0 {
484+ None
485+ } else {
486+ Some ( sort. fetch as usize )
487+ } ;
488+
489+ match LogicalPlanBuilder :: from ( input) . sort ( sort_expr) ?. build ( ) ? {
490+ LogicalPlan :: Sort ( mut sort) => {
491+ sort. fetch = fetch;
492+ Ok ( LogicalPlan :: Sort ( sort) )
493+ }
494+ p => LogicalPlanBuilder :: from ( p) . limit ( 0 , fetch) ?. build ( )
495+ }
484496 }
485497 LogicalPlanType :: Repartition ( repartition) => {
486498 use datafusion:: logical_expr:: Partitioning ;
You can’t perform that action at this time.
0 commit comments