snowflake.snowpark.functions.object_insert¶
- snowflake.snowpark.functions.object_insert(obj: Union[Column, str], key: Union[Column, str], value: Union[Column, str], update_flag: Optional[Union[Column, str]] = None) Column [source]¶
Returns an object consisting of the input object with a new key-value pair inserted (or an existing key updated with a new value).
- Example::
>>> from snowflake.snowpark.functions import lit >>> df = session.sql( ... "select object_construct(a,b,c,d,e,f) as obj, k, v from " ... "values('age', 21, 'zip', 21021, 'name', 'Joe', 'age', 0)," ... "('age', 26, 'zip', 94021, 'name', 'Jay', 'age', 0) as T(a,b,c,d,e,f,k,v)" ... ) >>> df.select(object_insert(col("obj"), lit("key"), lit("v")).alias("result")).show() -------------------- |"RESULT" | -------------------- |{ | | "age": 21, | | "key": "v", | | "name": "Joe", | | "zip": 21021 | |} | |{ | | "age": 26, | | "key": "v", | | "name": "Jay", | | "zip": 94021 | |} | --------------------