```
SELECT
    number,
    leadInFrame(number) OVER w AS W
FROM numbers(10)
WINDOW w AS (ORDER BY number ASC Rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
LIMIT 3;

┌─number─┬─W─┐
│      0 │ 1 │
│      1 │ 2 │
│      2 │ 0 │ <-- W should be 3!
└────────┴───┘
```

In contrast:  https://www.db-fiddle.com/f/hNNECnp7YC3E2zBKBaxN6T/1
#include <Processors/QueryPlan/Optimizations/Optimizations.h>
#include <Processors/QueryPlan/ITransformingStep.h>
#include <Processors/QueryPlan/LimitStep.h>
#include <Processors/QueryPlan/TotalsHavingStep.h>
#include <Processors/QueryPlan/SortingStep.h>
#include <Common/typeid_cast.h>
namespace DB::QueryPlanOptimizations
{
static bool tryUpdateLimitForSortingSteps(QueryPlan::Node * node, size_t limit)
{
    if (limit == 0)
        return false;
    QueryPlanStepPtr & step = node->step;
    QueryPlan::Node * child = nullptr;
    bool updated = false;
    if (auto * sorting = typeid_cast<SortingStep *>(step.get()))
    {
        
        sorting->updateLimit(limit);
        updated = true;
        child = node->children.front();
    }
    
    
    if (child)
        tryUpdateLimitForSortingSteps(child, limit);
    return updated;
}
size_t tryPushDownLimit(QueryPlan::Node * parent_node, QueryPlan::Nodes &)