Skip to content
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

Running map() on a set may return an array #4855

Closed
philrz opened this issue Nov 3, 2023 · 1 comment · Fixed by #4860
Closed

Running map() on a set may return an array #4855

philrz opened this issue Nov 3, 2023 · 1 comment · Fixed by #4860
Assignees
Labels
bug Something isn't working

Comments

@philrz
Copy link
Contributor

philrz commented Nov 3, 2023

Repro is with Zed commit 3a40788.

Regarding the new map() function added in #4806, if I modify the complex value in the docs example to be a set type instead of an array, map() still returns a set.

$ zq -version
Version: v1.10.0-31-g3a40788b

$ echo '|["foo","bar","baz"]|' | zq -z 'yield map(this, upper)' -
|["BAR","BAZ","FOO"]|

However, if I put that set value inside of a record and have map() act on that value, now what comes back is an array.

$ echo '{m:|["foo","bar","baz"]|}' | zq -z 'yield map(m, upper)' -
["BAR","BAZ","FOO"]
@philrz philrz added the bug Something isn't working label Nov 3, 2023
mattnibs added a commit that referenced this issue Nov 4, 2023
Fix bug in map where the result container type was getting set
of the incorrect value.

Closes #4855
mattnibs added a commit that referenced this issue Nov 5, 2023
Fix bug in map where the result container type was getting set
of the incorrect value.

Closes #4855
@philrz
Copy link
Contributor Author

philrz commented Nov 5, 2023

Verified in Zed commit 07893a2.

Now the set value inside the record comes back from map() as a set.

$ zq -version
Version: v1.10.0-36-g07893a2b

$ echo '{m:|["foo","bar","baz"]|}' | zq -z 'yield map(m, upper)' -
|["BAR","BAZ","FOO"]|

Thanks @mattnibs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants