Spark 2.4 introduced new useful Spark SQL functions involving arrays, but I was a little bit puzzled when I found out that the result of
select array_remove(array(1, 2, 3, null, 3), null)
is null
and not [1, 2, 3, 3]
.
Is this the expected behavior? Is it possible to remove nulls using array_remove
?
As a side note, for now the alternative I am using is a higher order function in Databricks:
select filter(array(1, 2, 3, null, 3), x -> x is not null)
array_remove
depends on notion of equality, and equality withNULL
is undefined. – Englacial