ARRAY_COMPACT

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns an array with all NULL elements removed.

Syntax 

1ARRAY_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.

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

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

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!