- Categories:
Semi-structured Data Functions (Array/Object)
OBJECT_KEYS¶
Returns an array containing the list of keys in the input object.
Syntax¶
OBJECT_KEYS( <object> )
Arguments¶
Examples¶
The next example shows OBJECT_KEYS working with both an OBJECT and a VARIANT that contains a value of type OBJECT.
Create a table that contains columns of types OBJECT and VARIANT.
CREATE TABLE objects_1 (id INTEGER, object1 OBJECT, variant1 VARIANT);INSERT values:
INSERT INTO objects_1 (id, object1, variant1) SELECT 1, OBJECT_CONSTRUCT('a', 1, 'b', 2, 'c', 3), TO_VARIANT(OBJECT_CONSTRUCT('a', 1, 'b', 2, 'c', 3)) ;Retrieve the keys from both the OBJECT and the VARIANT:
SELECT OBJECT_KEYS(object1), OBJECT_KEYS(variant1) FROM objects_1 ORDER BY id; +----------------------+-----------------------+ | OBJECT_KEYS(OBJECT1) | OBJECT_KEYS(VARIANT1) | |----------------------+-----------------------| | [ | [ | | "a", | "a", | | "b", | "b", | | "c" | "c" | | ] | ] | +----------------------+-----------------------+