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/as_array below:

Website Navigation


AS_ARRAY | Snowflake Documentation

Categories:

Semi-structured and structured data functions (Cast)

AS_ARRAY

Casts a VARIANT value to an ARRAY value.

See also:

AS_<object_type> , AS_OBJECT

Syntax
AS_ARRAY( <variant_expr> )

Copy

Arguments
variant_expr

An expression that evaluates to a value of type VARIANT.

Returns

The function returns a value of type ARRAY or NULL:

Usage notes Examples

Create a table and load data into it:

CREATE OR REPLACE TABLE as_array_example (
  array1 VARIANT,
  array2 VARIANT);

INSERT INTO as_array_example (array1, array2)
  SELECT
    TO_VARIANT(TO_ARRAY('Example')),
    TO_VARIANT(ARRAY_CONSTRUCT('Array-like', 'example'));

Copy

Use the AS_ARRAY function in a query to cast a VARIANT value to ARRAY values:

SELECT AS_ARRAY(array1) AS array1,
       AS_ARRAY(array2) AS array2
  FROM as_array_example;

Copy

+-------------+-----------------+
| ARRAY1      | ARRAY2          |
|-------------+-----------------|
| [           | [               |
|   "Example" |   "Array-like", |
| ]           |   "example"     |
|             | ]               |
+-------------+-----------------+

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