---
schema_version: "1"
id: 37650fdd9b72a905f1fe1ec682b61311ac2dd0019c8a88bb0a93280936c104df
title: ARRAY_COMPACT
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/array-func/array-compact.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/array-compact.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 54efe34dcf2e8ad2d8fd9ce42478c60769a90426920f03fcdbf619733c941a6c
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `ARRAY_COMPACT`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Returns an array with all NULL elements removed.

## Syntax

```sql
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.

```sql
SELECT array_compact(array[1, null, 2]) AS result;
```

Returns `array[1, 2]`, with the NULL element removed.

## Related Documentation

- [Array Data Type](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/array.md)
