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

Stateful expressions in user defined functions #5092

Closed
mattnibs opened this issue Mar 27, 2024 · 1 comment · Fixed by #5093
Closed

Stateful expressions in user defined functions #5092

mattnibs opened this issue Mar 27, 2024 · 1 comment · Fixed by #5093
Assignees
Labels
bug Something isn't working

Comments

@mattnibs
Copy link
Collaborator

mattnibs commented Mar 27, 2024

Aggregations are supposed to carry separate state for each textual invocation but this rule breaks apart when using aggregation expressions in user defined functions. Observe:

func c(): ( count() )
yield [c(), c(), c()]

currently returns

[1,2,3]

when it should be returning [1,1,1].

@mattnibs mattnibs added the bug Something isn't working label Mar 27, 2024
@mattnibs mattnibs self-assigned this Mar 27, 2024
mattnibs added a commit that referenced this issue Mar 27, 2024
This commit fixes an issue with using aggregation expressions user-defined
functions where there wasn't a separate state per textual invocation.

Closes #5092
mattnibs added a commit that referenced this issue Mar 27, 2024
This commit fixes an issue with using aggregation expressions user-defined
functions where there wasn't a separate state per textual invocation.

Closes #5092
nwt pushed a commit that referenced this issue Jun 6, 2024
This commit fixes an issue with using aggregation expressions user-defined
functions where there wasn't a separate state per textual invocation.

Closes #5092
mattnibs added a commit that referenced this issue Jun 7, 2024
This commit fixes an issue with using aggregation expressions user-defined
functions where there wasn't a separate state per textual invocation.

Closes #5092
@philrz
Copy link
Contributor

philrz commented Jun 19, 2024

Verified in Zed commit 9c3f5fd.

The example program now returns the expected output that reflects separate state with each invocation.

$ zq -version
Version: v1.15.0-42-g9c3f5fdc

$ zq 'func c(): ( count() ) yield [c(), c(), c()]'
[1(uint64),1(uint64),1(uint64)]

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