OBJECT_INSERT - Snowflake Documentation
A Boolean flag that, when set to TRUE, specifies that the input value updates the value of an existing key in the OBJECT value, rather than inserting a new key-value pair.
Searching…
A Boolean flag that, when set to TRUE, specifies that the input value updates the value of an existing key in the OBJECT value, rather than inserting a new key-value pair.
The Snowflake OBJECT_INSERT function returns an object consisting of the input object with a new key-value pair inserted or an existing key updated with a new value.
UPDATE only supports column operations so your approach won't work. Rebuilding the catalog, as below, will work (but it does make me pause and wonder if there's a better way.)
6 You should use Snowflake's VARIANT data type in any column holding JSON data. Let's break this down step by step:
The constructed object does not necessarily preserve the original order of the key-value pairs. In many contexts, you can use an OBJECT constant (also called an OBJECT literal) instead of the OBJECT_CONSTRUCT function.
JSON data is semi-structured, based on a text format used for storing and exchanging data. It consists of key-value pairs.
All of which takes us from our original JSON, with two value entries for each key, to our new "a2o" object with a single value for each key. The syntax a2o:key_name will return that single value as an array data type.
Step1: Create a temporary table named customers_json with customers_data field of VARIANT data type. We are creating a temporary table just as a POC to not retain data longer.
In JSON, an object (also called a “dictionary” or a “hash”) is an unordered set of key-value pairs. TO_JSON and PARSE_JSON are (almost) converse or reciprocal functions.
To construct a JSON object with key-value pairs, we use the OBJECT_CONSTRUCT function. This function takes pairs of arguments, where the first is a key and the second is a value.