• Varun Gupta's avatar
    MDEV-18431: Select max + row_number giving incorrect result · a4e58882
    Varun Gupta authored
    The issue here was when we had a subquery and a window function in an expression in
    the select list then subquery was getting computed after window function computation.
    This resulted in incorrect results because the subquery was correlated and the fields
    in the subquery was pointing to the base table instead of the temporary table.
    
    The approach to fix this was to have an additional field in the temporary table
    for the subquery and to execute the subquery before window function execution.
    After execution the values for the subquery were stored in the temporary table
    and then when we needed to calcuate the expression, all we do is read the values
    from the temporary table for the subquery.
    a4e58882
win.result 73.4 KB