with recursive cte as(
    select
        fdate,
        user_id,
        1 as depth
    from
        tb_dau

    union all
    
    select
        t.fdate,
        t.user_id,
        depth + 1 as depth
    from
        tb_dau t
    join
        cte c on c.user_id  = t.user_id
    where
        date_add(c.fdate, interval 1 day) = t.fdate
)

select
user_id,
max(depth) as max_consec_days
from
cte
group by user_id