OBJECT_DELETE
functionsupportedCore SQL functionsReturns an object containing the contents of the input (that is, source) object with one or more keys removed.
Syntax
supportedpartialnot supportednot scored
OBJECT_DELETE( <object>, <key1> [, <key2>, ... ] )
Parameters
| Name | Required | Description |
|---|---|---|
object | required | The source object. |
key1, key2 | required | Keys to be omitted from the returned object. |
Returns
This function returns a value of type OBJECT.
Usage notes
- For structured OBJECTs:
- For the arguments that are keys, you must specify constants.
- If the specified key isn’t part of the OBJECT type definition, the call fails. For example, the following call fails because the OBJECT value doesn’t contain the specified key zip_code: Copy code SELECT OBJECT_DELETE( {'city':'San Mateo','state':'CA'}::OBJECT(city VARCHAR,state VARCHAR), 'zip_code' ); 093201 (23001): Function OBJECT_DELETE: expected structured object to contain field zip_code but it did not.
- The function returns a structured OBJECT value. The type of the OBJECT value excludes the deleted key. For example, suppose that you remove the city key: Copy code SELECT OBJECT_DELETE( {'city':'San Mateo','state':'CA'}::OBJECT(city VARCHAR,state VARCHAR), 'city' ) AS new_object, SYSTEM$TYPEOF(new_object); The function returns an OBJECT value of the type OBJECT(state VARCHAR), which doesn’t include the city key. +-----------------+----------------------------+ | NEW_OBJECT | SYSTEM$TYPEOF(NEW_OBJECT) | |-----------------+----------------------------| | { | OBJECT(state VARCHAR)[LOB] | | "state": "CA" | | | } | | +-----------------+----------------------------+
- If the function removes all keys from the OBJECT value, the function returns an empty structured OBJECT value of the type OBJECT(). Copy code SELECT OBJECT_DELETE( {'state':'CA'}::OBJECT(state VARCHAR), 'state' ) AS new_object, SYSTEM$TYPEOF(new_object); +------------+---------------------------+ | NEW_OBJECT | SYSTEM$TYPEOF(NEW_OBJECT) | |------------+---------------------------| | {} | OBJECT()[LOB] | +------------+---------------------------+ When the type of a structured OBJECT value includes key-value pairs, the names and types of those pairs are included in parentheses in the type (for example, OBJECT(city VARCHAR)). Because an empty structured OBJECT value contains no key-value pairs, the parentheses are empty.