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

Can't retrieve null value via record indexing using field name from record #5583

Open
philrz opened this issue Jan 17, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@philrz
Copy link
Contributor

philrz commented Jan 17, 2025

tl;dr

I expected the middle value returned to be the null but instead got error("missing").

$ echo '{field1:"UserID",field2:"SearchPhrase",field3:"State",r:{UserID:1,SearchPhrase:null,State:"CA"}}' | super -Z -c 'yield r[field1],r[field2],r[field3]' -
1
error("missing")
"CA"

Details

Repro is with super commit 66b20d0.

The retrieval works fine if I use static strings as the field names in the record index expression.

$ super -version
Version: v1.18.0-227-g66b20d0f

$ echo '{field1:"UserID",field2:"SearchPhrase",field3:"State",r:{UserID:1,SearchPhrase:null,State:"CA"}}' | super -Z -c 'yield r["UserID"],r["SearchPhrase"],r["State"]' -
1
null
"CA"

I looked back at the history of this one. The last time it worked correctly was back at commit 1338193.

$ zq -version
Version: v0.33.0-147-g1338193f

$ echo '{field1:"UserID",field2:"SearchPhrase",field3:"State",r:{UserID:1,SearchPhrase:null,State:"CA"}}' | zq -z 'yield r[field1],r[field2],r[field3]' -
1
null
"CA"

When the changes associated with #3532 arrived in the next commit, the null value stopped appearing entirely.

$ zq -version
Version: v0.33.0-148-g7d7184b7

$ echo '{field1:"UserID",field2:"SearchPhrase",field3:"State",r:{UserID:1,SearchPhrase:null,State:"CA"}}' | zq -z 'yield r[field1],r[field2],r[field3]' -
1
"CA"

Thing stayed like that for a while, then with the changes in #3569 it started coming back as error("missing") as we see through today.

$ zq -version
Version: v0.33.0-172-g4fb52305

$ echo '{field1:"UserID",field2:"SearchPhrase",field3:"State",r:{UserID:1,SearchPhrase:null,State:"CA"}}' | zq -z 'yield r[field1],r[field2],r[field3]' -
1
error("missing")
"CA"
@philrz philrz added the bug Something isn't working label Jan 17, 2025
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

No branches or pull requests

1 participant