Fix for row number window function optimization