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

Reset stateful expressions on EOS #5069

Merged
merged 1 commit into from
Jun 7, 2024
Merged

Reset stateful expressions on EOS #5069

merged 1 commit into from
Jun 7, 2024

Conversation

mattnibs
Copy link
Collaborator

@mattnibs mattnibs commented Mar 13, 2024

This commit fixes a bug where stateful expressions were not getting reset when an op encounters EOS. This would most notably result in unexpected values when using stateful expressions inside of lateral queries.

Closes #4943
Closes #4937

@mattnibs mattnibs requested a review from a team March 13, 2024 22:08
compiler/kernel/expr.go Outdated Show resolved Hide resolved
runtime/sam/op/router.go Outdated Show resolved Hide resolved
This commit fixes a bug where stateful expressions used in ops were not
getting reset when the op encountered EOS. This would most notably result
in unexpected values when using stateful expressions inside of lateral
queries.

Closes #4943
Copy link
Member

@nwt nwt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need a stack

arena *zed.Arena // For zed.Values created during compilation.
deletes *sync.Map
funcs map[string]expr.Function
resetters expr.Resetters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need an expr.Resetters stack here to handle stateful expressions nested at different levels correctly but this looks good for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the one area for concern here is with over expressions. Everywhere else we just collect resetters for the expressions before recursing down into the flowgraph.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revisit.

@mattnibs mattnibs merged commit 2084cd5 into main Jun 7, 2024
3 checks passed
@mattnibs mattnibs deleted the reset-stateful branch June 7, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

count() in lateral query not resetting to zero union with count limit
2 participants