-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: implement array functions for JSON arrays
My answer on https://stackoverflow.com/questions/72347170/delete-element-from-jsonb-array-in-cockaroachdb/72351955#72351955 made me sad, and it's not the first time I've had trouble manipulating a JSONB array. There are a few different, non-mutually-exclusive ways we could make this easier. We could allow aggregate(generator) functions in scalar contexts. We could implement more JSON functions as needed. This PR instead just overloads every function that takes a json[] argument (which is a datum type we don't allow in columns) to also be able to take a json array argument, and alters the return type accordingly. It's not particularly performance-optimized but we can replace individual implementations if needed. That said, this is an unauthorized spike, what do you think? Release note (sql change): Built-in array functions array_append, array_prepend, array_cat, array_remove, array_replace, array_position, and array_positions may now be used with jsonb arrays.
- Loading branch information
Showing
3 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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