Casts a VARIANT value to an ARRAY value.
AS_ARRAY( <variant_expr> )
Copy
Arguments¶variant_expr
An expression that evaluates to a value of type VARIANT.
The function returns a value of type ARRAY or NULL:
If the type of the value in the variant_expr
argument is ARRAY, the function returns a value of type ARRAY.
If the type of the value in the variant_expr
argument doesn’t match the type of the output value, the function returns NULL.
If the variant_expr
argument is NULL, the function returns NULL.
This function doesn’t support a structured type as an input argument.
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