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

Website Navigation


OBJECT_PICK | Snowflake Documentation

Categories:

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

OBJECT_PICK

Returns a new OBJECT containing some of the key-value pairs from an existing object.

To identify the key-value pairs to include in the new object, pass in the keys as arguments, or pass in an array containing the keys.

If a specified key is not present in the input object, the key is ignored.

Syntax
OBJECT_PICK( <object>, <key1> [, <key2>, ... ] )

OBJECT_PICK( <object>, <array> )

Copy

Arguments
object

The input object.

key1, key2

One or more keys identifying the key-value pairs that should be included in the returned object.

array

Array of keys identifying the key-value pairs that should be included in the returned object.

Returns

Returns a new OBJECT containing the specified key-value pairs.

Usage notes

For structured OBJECTs:

Examples

The following example calls OBJECT_PICK to create a new object that contains two of the three key-value pairs from an existing object:

SELECT OBJECT_PICK(
    OBJECT_CONSTRUCT(
        'a', 1,
        'b', 2,
        'c', 3
    ),
    'a', 'b'
) AS new_object;
+------------+
| NEW_OBJECT |
|------------|
| {          |
|   "a": 1,  |
|   "b": 2   |
| }          |
+------------+

Copy

In the example above, the keys are passed as arguments to OBJECT_PICK. You can also use an array to specify the keys, as shown below:

SELECT OBJECT_PICK(
    OBJECT_CONSTRUCT(
        'a', 1,
        'b', 2,
        'c', 3
    ),
    ARRAY_CONSTRUCT('a', 'b')
) AS new_object;
+------------+
| NEW_OBJECT |
|------------|
| {          |
|   "a": 1,  |
|   "b": 2   |
| }          |
+------------+

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