-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Implement map_extract_first
#14175
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
Implement map_extract_first
#14175
Conversation
Creating |
@Tishj I thought the point of map_extract returning a list was to differentiate between a value being NULL and not present at all. Although I agree that it does add a lot of friction, now that we have map_contains and |
Hmm that makes some sense, I hadn't thought of that |
Also, I'm not sure if it has an impact here, but there is a difference between struct extract and map extract in case-insensitivity struct keys are case-insensitive, map keys aren't, since they're regular varchars, not identifiers, they are case-sensitive |
Json extract keys are also case sensitive, but we allow dot notation for that too, so this is consistent with that, at least. |
Also, we also cannot differentiate between |
Yea I agree, but like I said that would break backwards compatibility, so it's a question if we want to do that. I think either Hannes or Mark should make this call, I'd be in favor of having |
Thanks for the PR! I think the reason I would be in favor of changing In any case we should not be modifying the signature of |
Thanks for the discussion and feedback. I've removed |
I've added the "Needs documentation" label as this PR now changes the behavior of |
Thanks! LGTM - we just need to make sure to mention this change in behavior in the release notes |
This PR is a follow-up from #14175 that changed the return value of `map_extract` and `element_at` to return a single value from maps by key instead of a list with the value. This is a good change, but unfortunately It breaks backwards/forwards compatibility for serialized query plans. This PR fixes it by reverting the change to `map_extract` but instead add a new `map_extract_value` with the new behavior. It also changes the syntax sugar (e.g. `[]`) to use this new function instead, so the end user still "mostly" sees the new behavior, while the system internally still keeps the same behavior for the actual function.
Fixes #14167 - not a bug, but behavior is now different.
We used to auto-detect
STRUCT
, but we now auto-detectMAP
, and dot-notation for extracting fields no longer works for certain inputs.However, if we implement
map_extract_first
and rewrite dot-notation onMAP
s to this function we can still do the previous behavior.Since this is not a bugfix but somewhat of a feature we could consider pointing this to the
feature
branch instead.