Supporting map_from_entries(subquery) #20542
Closed
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.
I hereby agree to the terms of the [RisingWave Labs, Inc. Contributor License Agreement](https://raw.githubusercontent.com/risingwavelabs/risingwave/17af8a747593ebdbfa826691daf75bdab7d14fa0/.github/contributor-license-agreement.txt).
What's changed and what's your intention?
Summary of Changes
map_from_entries
to accept a set of rows (setof anyelement
) in addition to arrays for better usability.map_from_entries
without wrapping subqueries inARRAY(...)
, improving developer experience.map_from_entries(anyarray)
) remains unchanged for backward compatibility.Detailed Changes
Introduced a new function overload:
map_from_entries(setof anyelement) -> anymap
Preserved backward compatibility:
map_from_entries(anyarray)
) remains unchanged.ARRAY(...)
syntax will still work.Handled duplicate keys gracefully:
Example Queries & Behavior
✅ New behavior (set of rows directly passed in)
Output:
{a:1, b:2, c:3}
✅ Existing behavior still works (array of row entries)
Output:
{a:1, b:2, c:3}
❌ Error case (duplicate keys)
Expected: Query error due to duplicate key
'a'
.Checklist
setof anyelement
version ofmap_from_entries
.rustdoc
comments.Release Note
map_from_entries
now supports both arrays and sets of rows (setof anyelement
).ARRAY(...)
, simplifying queries.