PHOENIX-7849 : Support LIST_APPEND operator in BSON UpdateExpression SET (#2468)#2470
Merged
Conversation
…SET (apache#2468) Co-authored-by: Cursor <cursoragent@cursor.com>
virajjasani
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Adds the
$LIST_APPENDoperator to the BSON SET update-expression layer inUpdateExpressionUtils. Inside a$SETblock the new operator accepts:Each operand resolves to a
BsonArrayvia one of:BsonArrayBsonStringnaming a top-level or nested document path (existing value must be an array){ "$IF_NOT_EXISTS": { "<path>": <fallback> } }document whose resolved value must be an arrayThe result is
op1 ⧺ op2with order and duplicates preserved. The operator slots in alongside the existing$ADD/$SUBTRACT/$IF_NOT_EXISTScases ingetNewFieldValue; the resolvedBsonArrayis then written back via the existing nested-path SET machinery, so no changes are required toupdateNestedField,updateArrayAtLeafNode, orupdateDocumentAtLeafNode. Nested$LIST_APPENDoperands and arity ≠ 2 are explicitly rejected.Why are the changes needed?
The BSON update-expression engine today supports
$SET/$UNSET/$ADD/$DELETE_FROM_SET/$IF_NOT_EXISTS/ arithmetic$ADD/$SUBTRACT, but has no primitive for appending to an existing list. Downstream services that maintain append-only queues or event lists in a BSON column have to perform a read-modify-write cycle today, which doesn't compose with the atomic single-statement semantics the other operators already provide. This change rounds out the list-valued update surface so an append (or create-or-append) composes naturally with sibling$ADD/$IF_NOT_EXISTSclauses inside the same$SETblock.Does this PR introduce any user-facing change?
Yes — a new optional operator
$LIST_APPENDis accepted inside$SET. No existing behavior changes: update expressions that did not use$LIST_APPENDpreviously continue to be evaluated identically.How was this patch tested?
15 new unit tests in
UpdateExpressionUtilsTestcovering:$IF_NOT_EXISTS),$IF_NOT_EXISTSwith an empty-array fallback,$IF_NOT_EXISTS, path to a non-array, non-array:placeholder,$IF_NOT_EXISTSfallback that resolves to a non-array, nested$LIST_APPEND, arity ≠ 2),nested.queue),matrix[0]),$ADDin the same$SETblock.Runs in ~0.7s.
UpdateExpressionUtilsTest: 23/23 pass (8 pre-existing + 15 new).1 new end-to-end IT in
Bson2IT.testListAppendUpdateExpressionexercising the full SQL → BSON wire pipeline viaBSON_UPDATE_EXPRESSION(...)inON DUPLICATE KEY UPDATE. Two write-then-read phases on one row: a basic append to an existing list, and a create-or-append using$IF_NOT_EXISTScomposed with a sibling$ADDon a numeric counter in the same$SET. 1/1 pass in ~57s on the standard mini-cluster.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.7)