Viraj Jasani created PHOENIX-7647: ------------------------------------- Summary: BSON_UPDATE_EXPRESSION() set value if field key does not exist Key: PHOENIX-7647 URL: https://issues.apache.org/jira/browse/PHOENIX-7647 Project: Phoenix Issue Type: Improvement Reporter: Viraj Jasani
In order to provide the conditional update to the given path of the document, new internal function can be used by BSON_UPDATE_EXPRESSION() such that it helps set the given key-value pair in the document only if the document key path does not exist. For instance, {code:java} { "$SET": { "key1": "val1", "key2": 10.2345, "key3": { "$IF_NOT_EXISTS": { "key3": "val3" } }, "key9": { "$IF_NOT_EXISTS": { "key8": "val9" } }, "key4.key10": { "$IF_NOT_EXISTS": { "key4.key10": true } }, "key5.key11[2]": { "$IF_NOT_EXISTS": { "key5.key10": { "field123": "val123" } } } } } {code} With the above update expression, we are expecting to set the values of key1 and key2 with the respective values unconditionally. However, using $IF_NOT_EXISTS, conditional update is introduced. * The value of field "key3" will be set to "val3" only if "key3" does not exist, else it can be considered no-op. * The value of "key9" will be set to "val9" if "key8" does not exist, else the value of "key8" will be set to "key9". * The value of nested field "key10" within "key4" will be set to boolean true if it does not exist. * The value of nested array field "key5.key11[2]" will be set to document with single key-value pair "field123": "val123" if the nested field "key5.key10" does not exist. If it does exist, then the value of "key5.key10" will be set to "key5.key11[2]". -- This message was sent by Atlassian Jira (v8.20.10#820010)