You need to make sure that both arrays are array<date>
. In your example, the first array was array<string>
, which caused an error when you intersect it with an array<date>
.
select
size(
array_intersect(
transform(array("2021-12-02","2021-12-05","2021-12-10"), x -> date(x)),
sequence(to_date("2021-12-01"), date_add(to_date("2021-12-06"), -1), interval 1 day)
)
)
;
This query gives 2
.
For your initial question, you can try this query:
select
size(
array_intersect(
transform(array, x -> date(x)),
sequence(to_date(begin), date_add(to_date(end), -1), interval 1 day)
)
)
;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…