Get an end date, (n) workdays from a given date, using a calendar table

Impala version : impalad version 2.12.0-cdh5.16.2
As shown above, I have two tables; Customer table and Calendar Table, wich columns I describe below:
Customer Table:
[Customer] : Customer ID
[Date] : Creation date
[Num_Days] : Number of working days to calculate the [next_wkday] in the query result.
Calendar Table:
[civil_util] : when (1) -> workday; when (0) -> non working day
I need to get the query_result with the three columns of Customer Table and a calculated date [next_wkday], representing the number of working days [Num_Days] after the Creation date, jumping the zeros in the [civil_util] column.
The query below calculates the [next_wkday] using the Lead() function. But is not a solution because the offset parameter must be a constant, and we need to use the [Num_Days] value for each Creation Date:
select *,
Lead (to_date(ref_date),5) OVER (ORDER BY to_date(ref_date)) AS next_wkday,
datediff(Lead (to_date(ref_date),5) OVER (ORDER BY
to_date(ref_date)),ref_date) as days_diff
from cd_estruturais.calendario_datas
where
ref_date >= to_date(now())
and civil_util = 1
limit 1
So, we need to find another solution.
I need to say, for performance puposes, that the Customer table has 4 billion records approximatly.
Can anyone help please?

