-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: support PG14 JSON and ARRAY subscripting for UPDATE operations #77434
Comments
cc @vy-ton for prioritization |
82877: sql: support JSONB subscripting for SELECT cases r=mgartner a=otan I've kept the `ArraySubscript` class names and references as PG does this too. We can choose to change this in later iterations. Refs [#77434](#77434) Release note (sql change): Added support for JSONB subscripting in SELECT-style cases, e.g. SELECT json_field['a'] ... WHERE json_field['b'] = ... 83226: changefeedccl: block testfeed closure on canceled status r=samiskin a=samiskin Resolves #82794 TestChangefeedNemeses would sometimes flake on cloudstorage sink likely due to the feed writing files during the tempdirectory closing. Stress testing it on cloudstorage sink failed at 160 executions. This small change blocks feed.Close() on actually seeing the "cancelled" job status to ensure the feed is completely stopped prior to Close completing. Running cloudstorage Nemeses did not fail after 500+ executions. Release note: None Co-authored-by: Oliver Tan <[email protected]> Co-authored-by: Shiranka Miskin <[email protected]>
I've done SELECT support, but UPDATE is trickier and is deep into the weeds of the optimiser code. In #83764, i've added support for single SET statements, e.g. I imagine the following to be a small lift from that:
The bigger lifts will from supporting statements like these:
The future of supporting these kinds of statements is something that extends way outside my current knowledge. Probably needs a wordy discussion too. I'm no longer on SQL Experience with migrations work and have little time to follow up if this is a priority. Maybe a good intern / starter project for someone starting new on the queries team? Unassigning myself for now... |
https://www.postgresql.org/docs/14/datatype-json.html#JSONB-SUBSCRIPTING
8.14.5. jsonb Subscripting
The jsonb data type supports array-style subscripting expressions to extract and modify elements. Nested values can be indicated by chaining subscripting expressions, following the same rules as the path argument in the jsonb_set function. If a jsonb value is an array, numeric subscripts start at zero, and negative integers count backwards from the last element of the array. Slice expressions are not supported. The result of a subscripting expression is always of the jsonb data type.
UPDATE statements may use subscripting in the SET clause to modify jsonb values. Subscript paths must be traversable for all affected values insofar as they exist. For instance, the path val['a']['b']['c'] can be traversed all the way to c if every val, val['a'], and val['a']['b'] is an object. If any val['a'] or val['a']['b'] is not defined, it will be created as an empty object and filled as necessary. However, if any val itself or one of the intermediary values is defined as a non-object such as a string, number, or jsonb null, traversal cannot proceed so an error is raised and the transaction aborted.
Jira issue: CRDB-13589
Epic CRDB-12464
The text was updated successfully, but these errors were encountered: