Deep copy BytesRef when creating a constant vector block#141242
Merged
dnhatn merged 3 commits intoelastic:mainfrom Jan 29, 2026
Merged
Deep copy BytesRef when creating a constant vector block#141242dnhatn merged 3 commits intoelastic:mainfrom
dnhatn merged 3 commits intoelastic:mainfrom
Conversation
Collaborator
|
Hi @dnhatn, I've created a changelog YAML for you. |
Collaborator
|
Hi @dnhatn, I've updated the changelog YAML for you. |
Collaborator
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
nik9000
approved these changes
Jan 29, 2026
Member
Author
|
Thanks Nik! |
This was referenced Jan 29, 2026
dnhatn
added a commit
to dnhatn/elasticsearch
that referenced
this pull request
Jan 29, 2026
) Currently, when creating a constant BytesRef block or vector from a constant input, we do not deep copy the BytesRef in the evaluator. As a result, if the evaluator generates additional blocks afterwards, these blocks may share the underlying bytes with the constant block, leading to incorrect data. This issue was seen in tests where two rows had the same data when they should not. Closes elastic#140809 Closes elastic#140621 Closes elastic#140615
Collaborator
💔 Backport failed
You can use sqren/backport to manually backport by running |
dnhatn
added a commit
to dnhatn/elasticsearch
that referenced
this pull request
Jan 29, 2026
) Currently, when creating a constant BytesRef block or vector from a constant input, we do not deep copy the BytesRef in the evaluator. As a result, if the evaluator generates additional blocks afterwards, these blocks may share the underlying bytes with the constant block, leading to incorrect data. This issue was seen in tests where two rows had the same data when they should not. Closes elastic#140809 Closes elastic#140621 Closes elastic#140615
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jan 29, 2026
…141531) Currently, when creating a constant BytesRef block or vector from a constant input, we do not deep copy the BytesRef in the evaluator. As a result, if the evaluator generates additional blocks afterwards, these blocks may share the underlying bytes with the constant block, leading to incorrect data. This issue was seen in tests where two rows had the same data when they should not. Closes #140809 Closes #140621 Closes #140615
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jan 29, 2026
…141530) Currently, when creating a constant BytesRef block or vector from a constant input, we do not deep copy the BytesRef in the evaluator. As a result, if the evaluator generates additional blocks afterwards, these blocks may share the underlying bytes with the constant block, leading to incorrect data. This issue was seen in tests where two rows had the same data when they should not. Closes #140809 Closes #140621 Closes #140615
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.
Currently, when creating a constant
BytesRefblock or vector from a constant input, we do not deep copy theBytesRefin the evaluator. As a result, if the evaluator generates additional blocks afterwards, these blocks may share the underlying bytes with the constant block, leading to incorrect data. This issue was seen in tests where two rows had the same data when they should not.For example:
elasticsearch/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ParseIpLeadingZerosAreDecimalEvaluator.java
Line 54 in f32c348
and
elasticsearch/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/UrlDecodeEvaluator.java
Line 48 in 1af8b3e
In these cases, a constant BytesRef is created from the same bytesView of BreakingBytesRefBuilder.
For other vector/block types, we already copy the BytesRef to a new buffer, but this is not done for constant blocks. This change ensures that we always deep copy the input BytesRef when creating a constant vector or block. While in some cases the copy may not be necessary, the overhead is minimal and this approach is safer than requiring callers to handle the copy selectively.
Closes #140809
Closes #140621
Closes #140615