array_compact
function
Applies to: Databricks Runtime 12.2 LTS and above
Removes NULL elements from array
.
Syntax
array_compact(array)
Arguments
array
: An ARRAY expression.
Returns
The function returns an array of the same type as the input argument where all NULL values have been removed.
Examples
> SELECT array_compact(array(1, 2, NULL, 3, NULL, 3));
[1, 2, 3, 3]
> SELECT array_compact(array(NULL, NULL));
[]
Related functions
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for