ARRAY_COMPACT

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns an array with all NULL elements removed.

Syntax

array_compact(<array>)

Arguments

Required

  • <array>: The source array.

Returns

Returns an array with all NULL elements removed.

Considerations

  • Removes only NULL elements, not empty strings or zero values.
  • Non-NULL elements maintain their original order.

Examples

Remove NULL Elements

Remove all NULL values from an array.

SELECT array_compact(array[1, null, 2]) AS result;

Returns array[1, 2], with the NULL element removed.

Related Documentation