Bug fix, First accumulator multiple batch aware#6503
Merged
mustafasrepo merged 2 commits intoapache:mainfrom Jun 1, 2023
synnada-ai:feature/first_bug_fix
Merged
Bug fix, First accumulator multiple batch aware#6503mustafasrepo merged 2 commits intoapache:mainfrom synnada-ai:feature/first_bug_fix
mustafasrepo merged 2 commits intoapache:mainfrom
synnada-ai:feature/first_bug_fix
Conversation
Dandandan
approved these changes
May 31, 2023
alamb
approved these changes
May 31, 2023
| first: ScalarValue, | ||
| // At the beginning, `is_set` is `false`, this means `first` is not seen yet. | ||
| // Once we see (`is_set=true`) first value, we do not update `first`. | ||
| is_set: bool, |
Contributor
There was a problem hiding this comment.
Another potential way that might let the compiler check that is_set was updated correctly would be something like:
struct FirstValueAccumulator {
/// None until the data has been seen
first: Option<ScalarValue>
}
Contributor
Author
There was a problem hiding this comment.
I have considered this option, however, during evaluate call if first is None. We need to return NULL for appropriate type, such as ScalarValue::Int64(None) if type is Int64. However, datatype is only available during initialization. If we want to use Option for first, we may need to store data type also. Hence I opted for this approach
Contributor
|
Thanks @mustafasrepo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #6502.
Rationale for this change
Previously first_value accumulator was giving the first value of the last batch received as result. It wasn't aware of whether first_value was set at previous batches or not. Hence when working with multiple batch data the results produced were wrong. This PR fixes this problem.
What changes are included in this PR?
Are these changes tested?
Yes, new unit test is added for this new behavior.
Are there any user-facing changes?