A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/array_compact below:

ARRAY_COMPACT | Snowflake Documentation

Reference Function and stored procedure reference Semi-structured and structured data ARRAY_COMPACT
Categories:

Semi-structured and structured data functions (Array/Object)

ARRAY_COMPACT

Returns a compacted array with missing and null values removed, effectively converting sparse arrays into dense arrays.

Syntax
ARRAY_COMPACT( <array1> )

Copy

Arguments
array1

The source array.

Usage notes Examples

This example shows how to use ARRAY_COMPACT():

Create a simple table and data:

CREATE TABLE array_demo (ID INTEGER, array1 ARRAY, array2 ARRAY);

Copy

INSERT INTO array_demo (ID, array1, array2) 
    SELECT 2, ARRAY_CONSTRUCT(10, NULL, 30), ARRAY_CONSTRUCT(40);

Copy

Execute the query:

SELECT array1, ARRAY_COMPACT(array1) FROM array_demo WHERE ID = 2;
+--------------+-----------------------+
| ARRAY1       | ARRAY_COMPACT(ARRAY1) |
|--------------+-----------------------|
| [            | [                     |
|   10,        |   10,                 |
|   undefined, |   30                  |
|   30         | ]                     |
| ]            |                       |
+--------------+-----------------------+

Copy


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4